Quotes matlab please help

19 views (last 30 days)
BBB
BBB on 17 Jan 2021
Commented: dpb on 18 Jan 2021
hi. this is so simple issue yet i am not sure what to do. while displaying or just ploting something,or defining something in matlab we say " syms 'x' " right? but i dont have that quotes in my keyboaard i guess, or i am totally missing something. that symbol is ' but i have ' . It doesnt look different in here so i am adding a photo. They were in same font i cant do that 90 degree quotes in my keyboard helpp
  2 Comments
Stephen23
Stephen23 on 18 Jan 2021
Because no(?) common keyboard layout contains the complete set of typographers quotation marks, so-called "smart-quotes" is a feature of word-processing applications (not MATLAB), e.g.:
Note that curly single/double quotation marks are not part of ASCII and as such are not part of MATLAB code.
dpb
dpb on 18 Jan 2021
This wouldn't have anything to do with using the new fancy scripting environment rather than the command window by any chance, would it? I've never opened it so know nothing about it, so just totally off the wall...

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 17 Jan 2021
What layout is your keyboard setup? On my 104 key US-QWERTY the single quote character used to create a char vector is immediately to the left of the Enter key while the other single quote character is immediately above my Tab key.
For the specific command you indicated, as a workaround you don't actually have to type the ' character. You could use command form:
syms x
which is equivalent to the function form (I'm changing the variable name so you can see they both work):
syms('y')
Or you could use double quotes to make a string array if you're using a release of MATLAB from the past couple years.
syms("z")
whos x y z
Name Size Bytes Class Attributes x 1x1 8 sym y 1x1 8 sym z 1x1 8 sym
  6 Comments
Rik
Rik on 17 Jan 2021
Word (and many other rich text editors) will convert single quotes to the rounded quotes you showed in your screenshot. Matlab should not do that. Unless there is something strange with your keyboard layout (e.g. some RGB keyboard software?) or something very strange with your Matlab configuration this should not be happening.
Steven Lord
Steven Lord on 18 Jan 2021
dpb: If you had to you could call transpose or ctranspose to work around the single quote not working. It is more typing, but it is possible.
Rik: I've gotten so annoyed with Microsoft Word's automatic replacement with "smart quotes" when I'm typing code into a Word document or an email in Microsoft Office that I disabled that option.
Bilge Bengi Boyraz: if you're using a sufficiently recent release of MATLAB (I want to say release R2016b or later, but I'm not certain) then you can define a string array using the double quote character and most if not all of the functions that can operate on char arrays can also operate on string arrays.
D = ["Doc", "Dopey", "Happy", "Sneezy", "Sleepy", "Grumpy", "Bashful"];
D2 = sort(D)
Also if your keyboard has the single quote character "at 2" then you're not using a US QWERTY keyboard. Can you attach a picture of your keyboard to either your original question or to a comment?
Are you typing this code into MATLAB (the MATLAB Command Window or MATLAB Editor) or into a Word document or Outlook email?
Finally, if you're using Microsoft Windows one of the accessibility tools that it provides is an on-screen keyboard. Open the Start menu and start typing "on-screen keyboard". Try opening that and see if it's possible to type the correct single quote character into MATLAB using that keyboard. This will serve as both a diagnostic step and a potential workaround.

Sign in to comment.

Categories

Find more on Entering Commands in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!