''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

Answers (1)

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);

Categories

Asked:

on 16 Mar 2016

Answered:

on 17 Mar 2016

Community Treasure Hunt

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

Start Hunting!