system function cmdout has ' to the end

I am running MATLAB on CentOS7. When using "system" function, the cmdout always has an additional ' to the end which is pretty inconvenient, at least in my case. May I ask why the ' is there and how to supress it. Anything better than having to use cmdout(1:end-1) is welcome. Thanks.
[status,cmdout]=system('cat /proc/cpuinfo| grep "processor"| wc -l')
status =
0
cmdout =
'56
'

回答 (1 件)

Rik
Rik 2020 年 9 月 1 日
編集済み: Rik 2020 年 9 月 1 日

0 投票

That is not an additional apostrophe. Your char array has a newline character at the end. So that apostrophe is not part of the system response, just like the opening single quote isn't part of your char array.
You can remove the char(10) at the end if you prefer. Just remove the last element in the char array (like you suggested yourself), or remove all newlines from the output (cmdout(cmdout==newline)='';).

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 9 月 1 日

編集済み:

Rik
2020 年 9 月 1 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by