How to create a loop so i can compare accuracy of output values?
2 次查看(过去 30 天)
显示 更早的评论
I need to create a loop so that the process repeats itself until the output value is within a certain accuracy eg 10%
0 个评论
采纳的回答
Image Analyst
2016-4-1
Try this
loopCounter = 1;
maxIterations = 1000000; % or whatever would be the highest you ever expect.
tolerance = 0.001; % Whatever you want.
while loopCounter < maxIterations && difference1 < tolerance && difference2 < tolerance
difference1 = abs(yourValue1 - targetValue1);
difference2 = abs(yourValue2 - targetValue2);
% Now have code to update yourValues and get new ones.
yourValue1 = ......
yourValue2 = ......
loopCounter = loopCounter + 1; % Increment loop counter
end
8 个评论
Image Analyst
2020-10-3
How do you want to show them? Maybe with fprintf()? Maybe on a graph with yline()? I have no idea what you want. It's best to start your own question with your own data and code.
更多回答(1 个)
另请参阅
类别
在 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!