How do I write an if statement that says a variable is a error given a condition?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Temi O
am 7 Feb. 2019
Kommentiert: Kevin Phung
am 8 Feb. 2019
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
10 Kommentare
Kevin Phung
am 8 Feb. 2019
Did my answer below not give you an idea of how to increment the errorsCount?
Akzeptierte Antwort
Kevin Phung
am 7 Feb. 2019
%%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)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!