command window treats ' as apostrophe

when copying text into command window, it treats the ' symbol as an apostrophe, and gives an error. As the image below shows, when I go in and replace the slanted apostrophe with the ' on the command line, the code works fine. how can I get the command window to see the ' the first time instead of the slanted symbol? I have Matlab win10, not Matlab mobile, so I can't access any iSO to fix it.

7 comentarios

Walter Roberson
Walter Roberson el 29 de Mzo. de 2020
What is the source of the text you are copying?
Rodger Herbst
Rodger Herbst el 29 de Mzo. de 2020
I have been copying from MS word with no problems. But then I copied directly from a text file with the same result.
Walter Roberson
Walter Roberson el 29 de Mzo. de 2020
What is the source of the code in the text file?
MS Word tends to substitute ʼ characters for ' when "smart quotes" are enabled.
Code published in papers sometimes has ʼ because sometimes journal's rules require ʼ to be used to quote and the journals did not permit ' even for code. Or sometimes the author is careless in substituting characters if the journal requires ʼ in text but not code. Or sometimes a style sheet is at fault...
Rodger Herbst
Rodger Herbst el 30 de Mzo. de 2020
OK. Thanks for the heads up on MS word. But in my problem statement I noted that I also tried copying directly from aski text, and the problem persists.
Walter Roberson
Walter Roberson el 30 de Mzo. de 2020
Where did you get the ASCII text from? Was it a .m file, or was it an article of some sort?
I have done a lot of copying and pasting into MATLAB. I have never once seen it insert a ʼ character unless that character existed in the source.
I have occassionally seen sites where what you got when you used "copy" was not the same as what is displayed, but I was able to track those times to showing that the site was making something different available to the clipboard than it was rendering. (Sites that render mathematical formula often do that, since the rendered formulas are graphics and people generally want to copy the equation instead of the image of the equation.
Stephen23
Stephen23 el 30 de Mzo. de 2020
Editada: Stephen23 el 30 de Mzo. de 2020
"But in my problem statement I noted that I also tried copying directly from aski text, and the problem persists."
I very much doubt that. The ASCII character set includes
  • ' apostrophe char(39)
  • ` grave accent char(96)
but does NOT include a right single quote. For that you will need some other character encoding, e.g. Unicode:
  • ’ RIGHT SINGLE QUOTATION MARK (U+2019)
  • ‘ LEFT SINGLE QUOTATION MARK (U+2018) (here just for completeness)
Because no common keyboard layout includes a "right single quote" key, this character is almost always included in text as a result of an application converting the apostrophe character via a "Smart Quotes" feature.
Walter Roberson
Walter Roberson el 30 de Mzo. de 2020
Quite a number of years ago, one of the document editors I used (in the sense of a program that you would use to write a book complete with multiple columns, illustrations, and so on), the program treated the ' character as inputing ʼ unless you specifically used a sequence to change that. It was not a smart quotes feature, it was more a key mapping, because for manuscript purposes ʼ for contractions is more common than '

Iniciar sesión para comentar.

 Respuesta aceptada

Rodger Herbst
Rodger Herbst el 1 de Abr. de 2020

0 votos

Thank you both for your input, especially RE insights on ASCII character set. That should resolve my issue.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 29 de Mzo. de 2020

Respondida:

el 1 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by