Do I need to escape characters in this MATLAB string?

谁说我不能喝 提交于 2019-12-04 17:38:16

This should work:

[status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk ''{print $7}'' ');

You have to escape ' with another ' if you want it to appear as a character in a string. With respect to handling strings in MATLAB, ' is the only character with special meaning (it starts and ends the string), so it is the only one that needs escaping.

Caveat: Some functions may interpret their string arguments in different ways, and thus require certain characters to be escaped in different ways. These requirements will appear in the documentation for each function. A couple of these types of functions off the top of my head:

You'll need to escape the single quotes in the command string. Otherwise MATLAB will interpret them as the end of the string, and then break down on the stuff that follows it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!