how can jump and go to line
3 views (last 30 days)
Show older comments
singh
on 20 Apr 2015
Answered: Michael Haderlein
on 20 Apr 2015
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 Comments
Accepted Answer
Michael Haderlein
on 20 Apr 2015
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 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!