Search code examples
textquotation-marks

how to input single quotation mark in a text in matlab


trying to input the symbol ' - single quote inside a text will terminate the text. how to give the ' as input inside a text

a='; a='; | Error: String is not terminated properly.

msg='asdfasdfasdf'asdfasdf'; msg='asdfasdfasdf'asdfasdf'; | Error: Unexpected MATLAB expression.

In the first line i am trying to give single quote as input to a variable and in the next line i tried to give single quote in between. but both issues error. how can i solve this. kindly help me.


Solution

  • The answer can be found in many other questions by googling for two seconds... Just use double apostrophe.

    msg='abdabc''abcabc';
    

    Or alternatively:

    msg=strcat('abcabc', char(39), 'abcabc');