Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Tyler Kirsten
Tyler Kirsten am 17 Aug. 2018
Kommentiert: Tyler Kirsten am 18 Aug. 2018
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 Kommentar
Tyler Kirsten
Tyler Kirsten am 18 Aug. 2018
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?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by