How to create a loop so i can compare accuracy of output values?

조회 수: 4 (최근 30일)
James Dean
James Dean 2016년 4월 1일
댓글: Image Analyst 2020년 10월 3일
I need to create a loop so that the process repeats itself until the output value is within a certain accuracy eg 10%

채택된 답변

Image Analyst
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
James Dean
James Dean 2016년 4월 4일
Thank you. Final question.
How do i get it to show the 2 output values that are being used to compare accuracy at the end?
At the moment it shows a single output value and a graph (which is part for the rest).
Image Analyst
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개)

swapna subudhiray
swapna subudhiray 2020년 10월 1일
how to write a for loop for accuracy vs no of iteration?

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by