Problem plotting data in matlab GUI
이전 댓글 표시
Im taking data from arduino. Im using a button to start the data acquisition from arduino to matlab. This is the code.
function Send_Callback(hObject, eventdata, handles)
global tmax
delete(instrfind({'Port'},{'COM2'}));
s = serial('COM2','BaudRate',9600,'Terminator','CR/LF');
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
%Open port
fopen(s);
tmax = str2double(get(handles.edit2,'string'));
axes(handles.axes1);
axis([0 tmax 0 5.1] )
axes(handles.axes2);
axis([0 tmax 0 5.1] )
rate = 33;
i = 2;
t = 0;
% ejecutar bucle cronometrado
tic
AccelerationX = zeros(1,tmax*rate);
AccelerationY = zeros(1,tmax*rate);
while t<tmax
tic
t = toc;
a = fscanf(s,'%f,%f')';
AccelerationX(i)=a(1);
AccelerationY(i)=a(2);
% dibujar en la figura
x = linspace(0,i/rate,i);
set(handles.axes1,AccelerationX(1:i),x);
set(handles.axes2,AccelerationY(1:i),x);
drawnow
% seguir
i = i+1;
end
But i got this error when im trying to plot data.
Error using matlab.graphics.axis.Axes/set Invalid parameter/value pair arguments.
Error in ArduinoUnity3d>Send_Callback (line 155) set(handles.axes1,AccelerationX(1:i),x);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in ArduinoUnity3d (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ArduinoUnity3d('Send_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback
thanks
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!