how to make a computer go to a line in mfile for a repeat execution

1 visualización (últimos 30 días)
Hi, I need hints on codes to use to make a computer execution go to a particular line in mfile and repeat the program. example B=[2 4 6 8]; C=[1.5 3 4 5.6]; A = sum(B-C); if A>1; g to say line 3 ? else disp(A)

Respuesta aceptada

David Sanchez
David Sanchez el 15 de Abr. de 2014
Matlab does not have that kind of implementation. On the other hand, you can do a work around using conditionals, either whiles or ifs.
For example, instead of
B=[2 4 6 8];
C=[1.5 3 4 5.6];
A = sum(B-C);
if A>1
go to say line 3 ?
else
disp(A)
end
You might do: ( I know the example has no sense, but it's to take your lines as an example)
A = 10;
while A>1
B=[2 4 6 8];
C=[1.5 3 4 5.6];
A = sum(B-C);
end
disp(A)

Más respuestas (0)

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by