Can I run for loop in command window?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello
I have for loop with switch case in code , my code is here.
if true
for i=3:2:length(vx)
switch vx(i+1)-vx(i-1)
case -2
vx(i)=vx(i-1)-1
case -1
rowIdx=[i,i];
colIdx=[vx(i-1),(vx(i-1)-1)];
mat3Elements=X(sub2ind(size(X),rowIdx,colIdx));
[minValue,minIdx]=min(mat3Elements);
vx(i)=colIdx(minIdx);
case 0
rowIdx=[i,i,i];
colIdx=[vx(i-1),(vx(i-1)-1),(vx(i+1)+1)];
mat3Elements=X(sub2ind(size(X),rowIdx,colIdx));
[minValue,minIdx]=min(mat3Elements);
vx(i)=colIdx(minIdx);
case 1
rowIdx=[i,i];
colIdx=[vx(i-1),(vx(i-1)+1)];
mat3Elements=X(sub2ind(size(X),rowIdx,colIdx));
[minValue,minIdx]=min(mat3Elements);
vx(i)=colIdx(minIdx);
case 2
vx(i)= vx(i-1)+1; end end end
How can I run it in command window? when I paste whole of code in command window it didn't work.
Could you help me?
thamks
0 comentarios
Respuesta aceptada
Matt J
el 4 de Dic. de 2014
Editada: Matt J
el 4 de Dic. de 2014
when I paste whole of code in command window it didn't work.
It should have worked. Another option is to highlight the portion of code you want executed and press F9 (or righ-click and select "Evaluate Selection"). It will then execute at the command line.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps 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!