필터 지우기
필터 지우기

stop a cycle when finds the right value

조회 수: 3 (최근 30일)
ludvikjahn
ludvikjahn 2015년 3월 2일
답변: Julia 2015년 3월 2일
Good Morning, I am a new MAtlab user, and I have a simple question to ask: let's suppose that I have a range of data, for example:
112
145
178
190
267
367
852
...
and I want to find the nearest value to a precise value (f.e. 622), BUT I NEED to do it with a cycle structured more or less like that:
for i=1:3000
if 622+i = FOUND in the MATRIX
STOP (I don't know how to say stop in MATLAB)
end
Substantially, I must search the value step by step adding 1 to the default value.
Thanks

채택된 답변

Julia
Julia 2015년 3월 2일
Hi,
for leaving the loop you can use the break command.
For finding the nearest match I would try to use the find() function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by