how can jump and go to line

6 次查看(过去 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

采纳的回答

Michael Haderlein
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 个)

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by