How do I write an if statement that says a variable is a error given a condition?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Kevin Phung
2019-2-7
%%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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!