2D vector plot in MATLAB.

조회 수: 19 (최근 30일)
subho
subho 2011년 2월 27일
I have x, y, u and v datas. I am trying to do vector plot using quiver command in MATLAB. The plot is coming OK, but as there are many vectors the figure looks a bit clumsy. So Iwant to skip some vectors. Is it possible to do so using quiver in MATLAB or I have to use some other software? Kindly help. Say I want to skip 6 vectors. The vector plot as generated by Mr Oleg could have been generated just by potting in between x axis limits from -2.5 to 0. It may also be helpful if I can select with a mouse where to plot the vectors.
  댓글 수: 1
Jan
Jan 2011년 2월 27일
It would be helpful, if you explain the criteria to exclude vectors. Every second one or do you want to select them with the mouse?

댓글을 달려면 로그인하십시오.

답변 (1개)

Oleg Komarov
Oleg Komarov 2011년 2월 27일

Taking the example from quiver:

[X,Y] = meshgrid(-2:.2:2);
Z = X.*exp(-X.^2 - Y.^2);
[DX,DY] = gradient(Z,.2,.2);
% Plot
subplot(2,1,1)
quiver(X,Y,DX,DY)
set(gca,'Xlim', [-2.5 2.5], 'Ylim',[-2.5 2.5])
% Index just some vectors
idx = 1:10;
subplot(2,1,2)
quiver(X(:,idx),Y(:,idx),DX(:,idx),DY(:,idx))
set(gca,'Xlim', [-2.5 2.5], 'Ylim',[-2.5 2.5])

Oleg

카테고리

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