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

3 ビュー (過去 30 日間)
Tyler Kirsten
Tyler Kirsten 2018 年 8 月 17 日
コメント済み: Tyler Kirsten 2018 年 8 月 18 日
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 Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by