MATLAB: Repeating a for loop

loop

Res=input ('Enter the resistance values in ohm,R1 to Rn,values must be positive and real > ');
for i=1:1:n
if Res(1,i)<0 | imag(Res(1,i))~=0
Res=input ('Enter the resistance values in ohm,R1 to Rn,values must be positive and real > ');
end
end
how to make this code repeat from the begining from the bigginig if statement is true

Best Answer

n = 4 ;
for i=1:1:n
Res(i)=input ('Enter the resistance values in ohm,R1 to Rn,values must be positive and real > ');
while Res(i)<0
Res(i)=input ('Enter the resistance values in ohm,R1 to Rn,values must be positive and real > ');
end
end
Related Question