필터 지우기
필터 지우기

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

조회 수: 2 (최근 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 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