필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to form loop to jump from one element of matrix to other element.

조회 수: 1 (최근 30일)
Jagadesh Rao
Jagadesh Rao 2014년 11월 21일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi friends,
N_temp_failure= [ 938 945 955 2002 2003 4565 4566 4567 ];
Nx=937;
while Nx<=4567 ( i mean last element of N_temp_failure ).
Nx=Nx+0.001;
if Nx ==938
Nx= 945-1; (i mean it should jump to second element of N_temp_failure subtracted by 1 )
else
Nx=Nx;
end
end
it should repeat after Nx reaches every element of N_temp_failure, until it reaches the last element. N_temp_failure will always be in ascending order.
Please help me,
Advance Thanks Jagadesh Rao Thalur
  댓글 수: 2
Thorsten
Thorsten 2014년 11월 21일
편집: Thorsten 2014년 11월 21일
Add 0.001 to each element of N_temp_failure, unless the i'th element is 938, in this case you have to subtract 1 from the ith and the ith+1 element; is that what you want?
Jagadesh Rao
Jagadesh Rao 2014년 11월 22일
yes, you got it. you have a solution for it? please tell me.

답변 (1개)

Manoj
Manoj 2014년 11월 21일
Does this do what you want ?
N_temp_failure= [ 938 945 955 2002 2003 4565 4566 4567 ];
for ii=1:size(N_temp_failure,2)-1
Nx=N_temp_failure(ii)-1;
while Nx <= N_temp_failure(end);
Nx=Nx+0.001;
if Nx==N_temp_failure(ii)
Nx=N_temp_failure(ii+1)-1;
else
Nx=Nx;
end
end
end
  댓글 수: 2
Jagadesh Rao
Jagadesh Rao 2014년 11월 21일
actually your answer is partially correct, you should have put for loop inside while loop, you did the opposite. thanks
Jagadesh Rao
Jagadesh Rao 2014년 11월 22일
I tried this , this didn't work, it doesn't give the jump i asked for.
please try some other way.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by