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.

 採用された回答

Kelly Kearney
Kelly Kearney 2013 年 6 月 20 日

0 投票

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');

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeVector Fields についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by