Is there any alternative in matlab like Goto statement in C?. If so, can you please help me how to implement the given code in matlab.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Thenepalle Jayanth Kumar
am 16 Okt. 2015
Beantwortet: Walter Roberson
am 16 Okt. 2015
max=n*n-n;
I=1;
step0:
J=J+1;
if(J>=max+I) goto step10;
else goto step1;
step1:
v[I]=v[I-1]+d[J];
lb[I]=v[I]+cd[J+n-I]-cd[J];
if(lb[I]>=vt) goto step10;
else goto step2;
step2:
R=r[J];
C=c[J];
if(ir[R]==1) goto step0;
else goto step3;
step3:
if(ic[C]==1) goto step0;
else goto step4;
step4:
W=C; goto step5;
step10:
if(I==1) goto step12;
else goto step11;
}
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 16 Okt. 2015
This is exactly why the use of goto is ill-advised! It creates spaghetti code that is very hard to debug, translate, or read, as you will have noticed by now ...
My suggestion is to make a flow diagram from this code, using if-blocks. Then convert this into pseudo-code using while, for and if statements.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!