![]() |
我需要对这个MATLAB字符串中的字符进行转义吗?
我想在MATLAB中调用以下bash命令:
grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' 我在MATLAB中使用system() ,但事实证明有错误: >> [status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' '); ??? [status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' '); Error: Unbalanced or unexpected parenthesis or bracket. 我是否需要在MATLAB中将bash命令中的一些特殊字符作为字符串转义? [B]回答:[/B] 这应该工作: [status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk ''{print $7}'' '); 你必须逃离'与另一个'如果你想让它显示为一个字符串的字符。对于[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/strings.html"]在MATLAB中[/URL]处理[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/strings.html"]字符串[/URL] , '是唯一具有特殊含义的字符(它开始和结束字符串),因此它是唯一需要转义的字符。 [B]警告:[/B]某些函数可能以不同的方式解释其字符串参数,因此要求某些字符以不同的方式转义。这些要求将出现在每个功能的文档中。这些类型的功能中有一些是我无法想到的: [LIST][*] [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"]FPRINTF[/URL] / [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sprintf.html"]SPRINTF[/URL] : [I]format[/I]参数中出现的%和\字符必须分别转义为%%和\\ 。[*] [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/regexpi.html"]REGEXP / REGEXPI[/URL] :在正则表达式中[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f0-42649.html#f0-42808"]具有特殊含义的字符[/URL]必须以\ [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/regexpi.html"]开头[/URL] 。[/LIST] [url=https://stackoverflow.com/questions/2045197]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 04:55。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.