可以更改默认' n'matlab线终结器吗?我可以使用','而不是" n"?因为将读取它的串行端口被编程为终止时终止。任何答案都非常感谢!预先感谢!
使用eg:
ser = serial('COM1'); % establish connection between Matlab and COM1
set(ser, 'Terminator', 'CR'); % set communication string to end on ASCII 13
并将'CR'
替换为','
请参阅http://www.swarthmore.edu/natsci/ceverba1/class/e5/e5matlabexamples.htmlhttp://www.mathworks.co.uk/help/matlab/matlab_external/terminator.html
MATLAB中的一个简单字符串未由 n或 0终止,因为它是一个简单的字符数组,如下所示:
>> a = string('Hello World')
Warning: string is obsolete and will be discontinued.
Use char instead.
a =
Hello World
>> double(a)
ans =
72 101 108 108 111 32 87 111 114 108 100
将 0添加到末端,只需使用:
>> a(end+1)=0;
>> a
a =
Hello World
>> double(a) %the zero is there, but not printable as seen here
ans =
72 101 108 108 111 32 87 111 114 108 100 0