Another expression of inserting a quotation mark in a string is inserting a quotation mark in quotation marks. There are two solutions as far as I know.
- A recommended solution is using char(39) to generate the quotation mark. Char is a MATLAB function. This approach makes it much easy to read in eval function.
- There is another solution you can find in the Internet: using two quotation marks (without space between these two quotation marks) in a pair of quotation marks (this pair of quotation marks are used to indicate string) . It is possible to get lost with this approach if there are lots of quotation marks.
There is an example. Suppose we want to get a string
here 'is' a dog.
a =['here ' char(39) 'is' char(39) ' a dog']
a ='here ''is'' a dog'