Store the objects you create and then pass them into another function

조회 수: 1 (최근 30일)
Raldi
Raldi 2012년 7월 15일
Hi everyone
i have the following code, and what i want to do is somehow make it update each time the value of the component i move, not only the last one. Can anyone help.
Thanks
function test3
close; clear; clc;
compnum = 2;
compdata = [1,0.5,4,4;5.5,0.5,4,2];
xlim([0,10]),ylim([0,16])
for i = 1:compnum
h = imrect(gca, compdata(i,:));
addNewPositionCallback(h,@pu);
daspect([1,1,1])
end
function pu(pos)
compdata(i,:) = getPosition(h)
end
end
  댓글 수: 2
Jan
Jan 2012년 7월 15일
The tag "matlab code" is meaningless in a Matlab forum.
"clear" on top of a function is useless, because it clears all variables from the currently empty local workspace of the function. I'm convinced, that "close" and "clc" are not useful also.
What does "somehow make it update each time the value of the component i move" mean? What did you move and how do you do this?
Raldi
Raldi 2012년 7월 16일
Sorry for the wrong tag, and yes you are right about the clear and clc, i forgot thrm there from a previous try when this was not a function. I think i solved the problem though. Thanks for the help anyway

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by