addNewPositionCallback() problem

4 views (last 30 days)
clf
plot(0,0,'w')
axis equal
axis([0 1 0 1])
[x y]=ginput(1);
quiver(0,0,x,y,1);
axis equal
axis([0 1 0 1])
hold on
imp=impoint(gca,x,y);
addNewPositionCallback(imp, @(imp) quiver(0,0,imp(1),imp(2),1));
--------------------------------------------------------------------------------
I don't want it to spend plotting every moment i move the point, it's making shadow behind it, so i make the hold on to hold off, it don't plot that shadow of vector, but it change the figure size, and make an error, some one tell me what to do to move the vector where i ever want with out making such distortion.
Thanks for your help

Accepted Answer

Evanescent Devil
Evanescent Devil on 23 May 2012
function mv()
clf
plot(0,0,'w')
axis equal
axis([0 1 0 1])
[x y]=ginput(1);
quiver(0,0,x(1),y(1),1);
imp1=impoint(gca,x(1),y(1));
axis equal
axis([0 1 0 1])
addNewPositionCallback(imp1,@(imp1) qv(imp1(1),imp1(2)));
function qv(u,v)
hold off
quiver(0,0,u,v,1);
ip=impoint(gca,u,v);
addNewPositionCallback(ip,@(ip) qv(ip(1),ip(2)));
axis equal
axis([0 1 0 1])
end
end
--------------------------------------------------------------------------------
Solved, with the use of recursive function, but with a redundancy error :P

More Answers (1)

Evanescent Devil
Evanescent Devil on 23 May 2012
function mv()
clf
plot(0,0,'w')
axis equal
axis([0 1 0 1])
[x y]=ginput(1);
qv(x,y);
imp=impoint(gca,x,y);
addNewPositionCallback(imp,@(imp) qv(imp(1),imp(2)));
function qv(u,v)
quiver(0,0,u,v,1);
axis equal
axis([0 1 0 1])
end
end
--------------------------------------------------------------------------------
I found a solution, but it leads to another problem, The impoint disappears after i move the vector to the desired position, Also it shows an error.
Thanks for any help :D

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!