how can jump and go to line
조회 수: 7 (최근 30일)
이전 댓글 표시
suppose i create array and the i enter the no.this no will be checked in the first column of the array and then send other data from second and third column which is corresponding to the no.
in_zone=nonzeros(zone);
Y1=[X1(in_zone,:)]; % Y1 will contain coordinates value X and Y every in_zone
XY=horzcat(inzone,Y1) %XY will merge in_zone and Y1 value
N=input('enter the number :');
N1=find(XY(:,1)==N) %find the value from XY first column
N2=XY(N1,[2,3]) %this will show corresponding value of N1
X6=N2(1);
Y6=N2(2);
now i wish to create jump statement or alternative if no N is not found in XY first column then it will jump again to N.. thanks in advance
댓글 수: 0
채택된 답변
Michael Haderlein
2015년 4월 20일
There is no jump keyword in Matlab. You can just check like
N=input('enter the number :');
N1=find(XY(:,1)==N); %find the value from XY first column
if isempty(N1)
errordlg('Value does not exist!')
else
N2=XY(N1,[2,3]); %this will show corresponding value of N1
X6=N2(1);
Y6=N2(2);
end
Or, if you want to insist on a correct value:
N1=[];
while isempty(N1)
N=input('enter the number :');
N1=find(XY(:,1)==N); %find the value from XY first column
end
N2=XY(N1,[2,3]) %this will show corresponding value of N1
X6=N2(1);
Y6=N2(2);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Software Development Tools에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!