How to read UDP data into a vector/array in MATLAB App Designer?

2 次查看(过去 30 天)
I can't seem to read UDP data into a vector/array in App Designer. I can send a vector/array successfully and receive one in the command window if I try, but not from App Designer. I don't get any errors, it just doesn't work. Here is the code I am currently trying:
function ReadData(app) % read data from UDP values_recieved = fscanf(app.u); app.Recieve_values = str2double(values_recieved);
% update sensor values array
app.Recieve_values_array = [app.Recieve_values_array(2 : end); app.Recieve_values];
% update Speed and Torque gauge with the latest values
app.SpeedRPMGauge.Value = app.Recieve_values(4);
app.EditFieldSpeedLabel.Value = app.Recieve_values(4);
app.TorqueNmGauge.Value = app.Recieve_values(3);
app.EditFieldTorqueLabel.Value = app.Recieve_values(3);
% plot Torque sensor value vs Speed sensor value in GUI
% area(app.UIAxes, app.Recieve_values(4), app.Recieve_values(4), 'LineWidth', 2);
end
  1 个评论
Tyler Kirsten
Tyler Kirsten 2018-8-18
I changed the line: app.Recieve_values = str2double(values_recieved); to: app.Recieve_values = str2num(values_recieved); and it worked for perfectly for a while, then without changing anything it started giving me the same error again "Index exceeds matrix dimensions" and basically freezes the app.
Any ideas?

请先登录,再进行评论。

回答(0 个)

类别

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

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by