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 Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2013년 6월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by