''Not enough input arguments'' error. help me (ekg/emg)

i am trying to connect arduino card + ekg/emg sheild to matlab but everytime this error pops out.
Error using matlab_arduino (line 11)
Not enough input arguments.
i couldnt see the problem. help me please. here is the code
function matlab_arduino(nm) %function decleration
close all;
clc;
y=zeros(1,1000);
delete(instrfind({'Port'},{'COM4'}));
ps= arduino('COM4'); %connect to the arduino
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
cm=1;
grid on;
hold on;
while cm<=nm
ylim([0 5]);
xlim([cm-20 cm+5]);
y(cm)=ps.analogRead(0)*5/1024; %read the analog signal from arduino
plot(cm,y(cm),'X-r'); %plot the wave of the analog signal
drawnow
cm=cm+1;
end
delete(ps);
clear all;
end

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 3월 17일

0 개 추천

halil - the error message is telling you that you are not passing enough inputs into the function matlab_arduino. Since there is only one input, I suspect that you are calling it as
matlab_arduino
without passing in the nm input parameter. You need to figure out what this parameter should be (a number of some kind as it acts as an upper bound on the local variable cm) and pass it in as (for example)
nm = 42;
matlab_arduino(nm);

카테고리

도움말 센터File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

질문:

2016년 3월 16일

답변:

2016년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by