trying to convert IDL codes to MATLAB
Mostra commenti meno recenti
Hi i'm trying to create a similiar code on matlab to the one i have in IDL
Basically the code lets you select a box_cursor over a region of an image or select the x,y,nx,ny deminsions
the IDL codes are
roichox:
print,'PLEASE SELECT YOUR REGION OF INTEREST: 1=box, 2= enter values'
read,roichoice
case roichoice of
1: begin
box_cursor,x,y,nx,ny
print,"Margins and dimensions:",x,y,nx,ny
end
2: begin
print, 'x?'
read,x
;print, 'y?'
;read,y
print, 'nx?'
read,nx
;print,'ny?'
;read,ny
end
else: goto, roichox
endcase
my translation so far is
roichoice=input('PLEASE SELECT YOUR REGION OF INTEREST: 1=box, 2= enter values\n');
switch( roichoice)
case 1
[I ,rect]=imcrop();
yb=rect(1);
xb=rect(2);
nyb=rect(3);
nxb=rect(4);
fprintf('Margins and dimensions: x=%f y=%f nx=%f ny=%f',xb,yb,nxb,nyb);
case 2
xb=input('x?');
nxb=input( 'nx?');
otherwise
goto(roichox);
return
end
2 Commenti
John D'Errico
il 8 Ago 2017
You used goto? No goto in MATLAB. Try again.
dpb
il 9 Ago 2017
As John says, there is no GOTO in Matlab; leave the otherwise clause empty and enclose the block in a while loop. Use break when get a valid response to exit the block and go on to next step.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Interactive Control and Callbacks in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!