fscanf in simulink?

1 次查看(过去 30 天)
raymon saadalla
raymon saadalla 2017-6-21
I receive some strings in UDP. I can see them using fscanf. But I would like to have them in Simulink environment. I tried stream input block, but it seems that it's different from fscanf. Is there any way that I can monitor the strings, received via UDP, in Simulink? they are ascii value how can i read them in simulink

回答(1 个)

Walter Roberson
Walter Roberson 2017-6-21
Use a UDP receive block, for which the output type has been set to (or left at) uint8. Pass the output to a MATLAB Function Block. Inside the function block, char() the byte vector. You can sscanf() the resulting string.
  1 个评论
raymon saadalla
raymon saadalla 2017-6-21
编辑:raymon saadalla 2017-6-21
thanks, so i do something like that and this is my function block, but I keep getting not enough arguments error ? any idea why is that.
function output = func(data)
coder.extrinsic('sscanf')
x=sscanf(data)
channel0= x(20:23)
channel0 = strtrim(channel0);
channel0 = str2double(double(channel0))
output = coder.nullcopy(zeros(size(data)));
output = channel0;
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by