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