How to make a loop until the same result is obtained
이전 댓글 표시
Hello,
I need help how to be used correctly in the loop, I have here a parameter table.
Example: I have k that place in the equation so i get d=23.83 and cheak if that no same ,continue until is same Out=d.
Thanks for the helpers

for k=[2.73 2.56 2.47 2.42 2.39]
d=130-(K*(350/9));
if d/130==[0.1 0.18 0.23 0.26 0.28]
Out=d
end
end
댓글 수: 8
KSSV
2020년 11월 30일
d/130==[0.1 0.18 0.23 0.26 0.28]
The above line is not correct...
Emilia
2020년 11월 30일
KSSV
2020년 11월 30일
d/130==[0.1 0.18 0.23 0.26 0.28]
The above will give you logical indices...The exact question what you asked is not clear.
Emilia
2020년 11월 30일
for k=[2.73 2.56 2.47 2.42 2.39]
d=130-(k*(350/9)) ;
d/130
if any(d/130==[0.1 0.18 0.23 0.26 0.28])
Out=d
end
end
The values are close to two decimals...what to you want?
Emilia
2020년 11월 30일
Rik
2020년 11월 30일
So essentially you want to round to 2 decimals? Or do you have a variable number of digits you want to round to? And do you actually want to round the values, or just display them with 2 digits?
Emilia
2020년 11월 30일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!