Problem with quiver resolution

I try to plot a 100x100 matrix and want to plot direction arrows into a contour plot. My code thus far
[C,h]=contour(flipud(X),'Color','black'); [u,v]=pol2cart(flipud(rdir),1); quiver(u,v,0.5,'black');
There are so many arrows that its not possible to see the contour-plot behind it. It would be useful if there is a command that makes only each 2. arrow appear. I tried this: quiver(u(1:2:end,1:2:end),v(1:2:end,1:2:end),0.5,'black')
The result is that the matrix of the quiver plot is much smaller than the matrix of the contour plot and so the size of the plot changed as well. Do somebody have a suggestion? Thank you in advance.

 Akzeptierte Antwort

Kelly Kearney
Kelly Kearney am 20 Jun. 2013

0 Stimmen

When you don't provide any x or y matrices, both contour and quiver assume 1:#columns and 1:#rows as the x and y-coordinates, respectively. So just make sure you define x and y explicitly
[xq,yq] = meshgrid(1:size(u,2), 1:size(u,1));
[xc,yc] = meshgrid(1:size(X,2), 1:size(X,1));
contour(xc,yc,flipud(X), 'color', 'k');
hold on;
quiver(xq(1:2:end,1:2:end),yq(1:2:end,1:2:end), ...
u(1:2:end,1:2:end),v(1:2:end,1:2:end), 0.5, 'k');

Weitere Antworten (0)

Kategorien

Mehr zu Vector Fields finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by