Scale quiver plots using quiver or quiver2

2 vues (au cours des 30 derniers jours)
Jenny
Jenny le 23 Oct 2015
I have current speed and direction data in 10 min intervals (attached file).
I would like to quiver the plots (with time along the x-axis)and include a scale which represents the 'speed' of the current.
I have tried using both 'quiver' and 'quiver2' with no success. Quiver2 looks like a great function but I did not manage to get it to work. I also tried quiverscale.m with no good result.
I would greatly appreciate help in correctly scaling the quiver plot.
Jenny
My code so far:
DD_rad = (90-Dir5m).*pi./180;
[x1,y1]=pol2cart(DD_rad,Spd5m);
x2=x1(1:6:end);
y2=y1(1:6:end);
figure
set(gcf,'Units','Normalize','Position',[0.3 0 0.4 0.9])
t = (Date(1) + (1:length(x1))./(24*6))'; % Each element of x1 corresponds to 10min and not a day so need to divide by 24*6 (*60/10) since am adding 1 to every element of x1 to calc. t.
%t2=t(1:2:end); % plot every 2nd element
t2=t(1:6:end); % plot every 6th element
xmin=t(1);
xmax=t(end);
scaleFactor=4; % orig 4
%quiver(t2,zeros(size(x2)),x2,y2,'ShowArrowHead','off',scaleFactor); % does not plot with ShowArrowHead - off command.
quiver(t2,zeros(size(x2)),x2,y2,scaleFactor); % plotting every 6th current vector.
ylabel('[m/s]','Fontsize',12);
xlabel('Dato','Fontsize',12);
axis equal
xlim([xmin xmax]);
set(gca,'xtick',t2(1:96:end),'Fontsize',12);
% Change scaling of y-labels:
yTicks = get(gca,'YTick')';
set(gca,'YTickLabel',num2str(yTicks./(scaleFactor))); % scale factor was originally 4
% End scaling
datetick('x','dd.mm','keepticks');
hold off

Réponses (0)

Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by