how can jump and go to line

3 visualizaciones (últimos 30 días)
singh
singh el 20 de Abr. de 2015
Respondida: Michael Haderlein el 20 de Abr. de 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

Respuesta aceptada

Michael Haderlein
Michael Haderlein el 20 de Abr. de 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);

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by