trying to convert IDL codes to MATLAB
이전 댓글 표시
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
John D'Errico
2017년 8월 8일
You used goto? No goto in MATLAB. Try again.
dpb
2017년 8월 9일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!