MATLAB: I get a parse error when i’m tyring to use the Disp function in a loop!..Why is it so!..I just added a disp command infront of the if condition and it gives a parse and a syntax error!

editormedical

Here is the code that works: for i=1:length(RR_s) if sum(RR_s(i,:)<0.500)>=1 dRR_s(i,1)=k1*(RR_s(i,1)-RR_s(i,2)); else if sum(RR_s(i,:)>1)>=1 dRR_s(i,1)=k2*(RR_s(i,1)-RR_s(i,2)); else dRR_s(i,1)=RR_s(i,1)-RR_s(i,2); end end end
Here is the code that doesn't!:
for i=1:length(RR_s) disp(sum(RR_s(i,:)) if sum(RR_s(i,:)<0.500)>=1 dRR_s(i,1)=k1*(RR_s(i,1)-RR_s(i,2)); else if sum(RR_s(i,:)>1)>=1 dRR_s(i,1)=k2*(RR_s(i,1)-RR_s(i,2)); else dRR_s(i,1)=RR_s(i,1)-RR_s(i,2); end end end

Best Answer

disp( sum ( RR_s (i,:) )
% 1 2 3 3 2
Do you see the problem?