Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Tyler Kirsten
Tyler Kirsten el 17 de Ag. de 2018
Comentada: Tyler Kirsten el 18 de Ag. de 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 comentario
Tyler Kirsten
Tyler Kirsten el 18 de Ag. de 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?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by