30
Jun

eval命令中的单引号

在MATLAB的字符串中,对于单引号的使用有点儿乱。

但是基本上是一个大原则:字符串中的单引号,用两个单引号来定义(不是一个双引号)

例如:disp('M')可以在窗口输出一个M。那么如果我要输出一个'M'的话,就需要用如下命令:

disp(' ''M'' ');

这时,如果使用eval命令的字符串里面有单引号,就更麻烦了。

eval(’disp(”””M”””)’);%%注意:每两个引号中间不可以象disp那样有空格!

输出’M'。同样的功能还可以写成如下格式:

eval(['disp(','''','''''M''''','''',')']);

1 Comment so far

Leave a comment

Name(required)
Mail (will not be published)(required)
Website

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URIs must be fully qualified (eg: http://www.dupola.com) and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.