I am trying to plot velocity vectors but they are not getting displayed in a single graph.How can I do that?

2 次查看(过去 30 天)
I have the following code and I want all my vectors to be displayed in a single graph.But my code gives different graph for every iteration.How can I make them to be displayed in single graph.
n_mat_cell=cell(nframes-1,1); % this stores the n vectors of each component in previous frame
for n=1:nframes-1
n_mat_cell{n}=zeros(2, nclusters(n)); % 2 x number of components in previous frame
for i=1:nclusters(n)
[~,indx]=max(res_cell{n}(i,:));
n_mat_cell{n}(1,i)=caCentroids{n+1}(1,indx)-caCentroids{n}(1,i);
n_mat_cell{n}(2,i)=caCentroids{n+1}(2,indx)-caCentroids{n}(2,i);
quiver( n_mat_cell{n}(1,i),n_mat_cell{n}(2,i))
end
end

回答(1 个)

Alexandra Harkai
Alexandra Harkai 2016-11-3
hold on
% your code here
hold off
Where 'hold on' will 'Retain current plot when adding new plots' according to the Documentation, 'hold off' will turn the hold state off so new plots will clear existing plots.

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by