refreshdata, drawnow, ... nothing works?

9 次查看(过去 30 天)
Vinci
Vinci 2013-10-28
回答: Vinci 2013-10-29
Good evening
I'm currently working on a project where data from an embedded platform is fed into matlab in a loop. Some stuff gets calculated and plotted with the drawVector3d function from the famous geom3d lib (<http://www.mathworks.com/matlabcentral/fileexchange/24484-geom3d)>. It's basically just a nicer wrap for quiver3, but it makes my code way more readable...
The code with the actual plot looks like this:
if true
drawVector3d([0 0 0],R(1,:));
drawVector3d([0 0 0],R(2,:));
drawVector3d([0 0 0],R(3,:));
axis vis3d
axis([-1 1 -1 1 -1 1])
set(gca, 'YDir', 'reverse')
set(gca, 'ZDir', 'reverse')
hold;
end
Now the matrix "R" changes with each loop and I'd like to update my quiver3 plot accordingly. So far I've tried pretty much every combination I got from google, like refreshdata, drawnow or linkdata... but nothing worked.
I'd really appreciate it, if someone has a suggestion for me.
tia Vinci

回答(1 个)

Vinci
Vinci 2013-10-29
Hey there
Actually, I just figured it out! I didn't know that you can link U,V and W data from the quiver3 plot as well...
So at first I always had my vectors drawn from the endpoint from the previous vector to a new position instead of from the origin to the new position. Looking up the quivergroup properties helped (<http://www.mathworks.de/de/help/matlab/ref/quivergroupproperties.html)>!
if true
set(h1, 'XDataSource', '0', 'YDataSource', '0', 'ZDataSource', '0');
set(h2, 'XDataSource', '0', 'YDataSource', '0', 'ZDataSource', '0');
set(h3, 'XDataSource', '0', 'YDataSource', '0', 'ZDataSource', '0');
set(h1, 'UDataSource', 'r(1,1)', 'VDataSource', 'r(1,2)', 'WDataSource', 'r(1,3)');
set(h2, 'UDataSource', 'r(2,1)', 'VDataSource', 'r(2,2)', 'WDataSource', 'r(2,3)');
set(h3, 'UDataSource', 'r(3,1)', 'VDataSource', 'r(3,2)', 'WDataSource', 'r(3,3)');
linkdata on
end
Now the plot gets updated correctly.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by