I am trying to store values from serial monitor of Arduino to a vector in MATLAB.

1 次查看(过去 30 天)
if true
% code
end
function pushbutton1_Callback(hObject, eventdata, handles)
delete(instrfind)
theta=zeros(1,100000);
arduin=serial('COM3','BaudRate',9600); % create serial communication object on port COM18
fopen(arduin); % initiate arduino communication
CM(1)=0;
time(1)=0;
tic;
while (toc<=60) % stop after 60 secs
for i=1:100
theta(i)=fscanf(arduin,'%f');
end
end
fclose(arduin); % end communication with arduino
delete(arduin);
guidata(hObject, handles); It generates an error: Error in fyp>pushbutton1_Callback (line 90) theta(i)=fscanf(arduin,'%f');
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in fyp (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)fyp('pushbutton1_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by