How to write a "go to" -like statement in matlab
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi. Need a lil bit of help here. I normally work with fortran that supported a "go to" statement. Is there anyway that i could do the same ("go to" - like statement) using matlab? e.g.
if solution ==1
<do program statements A >
<do program statements B >
elseif solution ==2
<do program statements A (as previously stated above) only>
%this is where i normally used a go to previous line statement in fortran to avoid writing the same program statement twice.
end
Appreciate any help u can give
0 comentarios
Respuesta aceptada
Thomas
el 12 de Jun. de 2012
I dont think there is 'goto' in MATLAB you could use
try
..
catch
or use the file exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/26949-matlab-goto-statement
3 comentarios
Thomas
el 12 de Jun. de 2012
then it would be easier to use the File exchange submission I have linked to..
Sean de Wolski
el 12 de Jun. de 2012
no reason for goto or trycatch here/
Put the various statements in sub ffunction as Ilham has suggested.
Más respuestas (1)
Ilham Hardy
el 12 de Jun. de 2012
Seems better to put statement A and B as seperate functions or scripts. Then you can call them whenever and wherever you want.
Ver también
Categorías
Más información sobre Fortran with MATLAB 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!