Hi. I have a code as below:
x=input('Please enter value of x: ');y=input('Please enter value of y: ');z=input('Please enter value of z: ');V={'x','y','z'};Ktra=[x y z];for i=1:numel(Ktra) if Ktra(i)<0 disp('Value enter into must positive'); fprintf('Value of %s is negative \n',V{i}); endendSo, If i enter x = -9 and y = -6, program will give:Value enter into must positiveValue of x is negativeValue enter into must positiveValue of y is negativeAnd you can see, we have two warnings: "Value enter into must positive". It is unfavorable.So, how can i do to display that warning once?I mean that no matter how much I enter, it is just given a warning message. As below:Value enter into must positiveValue of x is negativeValue of y is negativeThank you so much!
Best Answer