MATLAB: How to write an if statement that says a variable is a error given a condition

errorif statementMATLAB

Please how do I write this 'if statement' in MATLAB notation? I ran a simulation N times and would like to find the error rate using an 'if statement'. I ran the simulation N number of times. How do I write that Y is an error if the statement below happens? And then calculate the errors in N number of trials?
if X=1.2||Y=0 && U1>U2
%How do I write that Y is an error if the above statement happens? And then calculate the number of errors in N number of trials?
end

Best Answer

%%outside forloop
errCnt = 0;
%% inside forloop
if X=1.2||Y=0 && U1>U2
%How do I write that Y is an error if the above statement happens?
disp(['Error found in iteration ' num2str(i)])
% And then calculate the number of errors in N number of trials?
errCnt = errCnt + 1;
end
%%
something like that. If you're looping through Y, dont forget to change it to Y(i)