Contouring a mesh and assigning magnitude arrows in Matlab
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I want to assign vector to a contourf graph, in order to show the direction and magnitude of wind. For this I am using contourf(A) and quiver(x,y), where as A is a matrix 151x401 and x,y are matrices with the same sizes (151x401) with magnitude and direction respectively.

When I am using large maps i get the position of the arrows but they are to densily placed and that makes the graph look bad.
The final graph has the arrows as desired, but they are to many of them and too close, I would like them to be more scarce and distributed with more gap between them, so as to be able to increase their length and at the same time have the components of the contour map visible.
Can anyone help , any pointers would be helpful
採用された回答
use
quiver(x(1:dx:end),y(1:dy:end),u(1:dy:end,1:dx:end),v(1:dy:end,1:dx:end))
where dx and dy are how many elements to skip. In this way, the arrows are spaced out.
10 件のコメント
Is the sequence I am using correct?
contourf(A)
hold
quiver(x(1:20:401),y(1:20:401))
It does not let me to over plot the arrows
thank you
Try using
hold on
Works for me...
George
2014 年 5 月 23 日
you can see the arrows of the quiver?
I cant :(
Sara
2014 年 5 月 23 日
How did you get the pic on the right then? Attach your script and your data, since it works for the random numbers I'm using, it may be a detail that differs.
contourf(mesh)
hold on
quiver(x(1:20:401),y(1:20:401))
These are the files, and the commands i use, if you open after the contour the property editor and isolate the quiver you will notice it has only placed 5 arrows at the beginning of the axis
thanks
the pic on the right i got it with
contourf(mesh)
hold on
quiver(x,y)
Ok, found the problem. You need to specify also the x and y coordinates of your points :). Try this and then replace xx and yy with your coordinates:
clc
clearvars
close all
load('matlab.mat');
[nx,ny] = size(A);
xx = 1:1:ny;
yy = 1:1:nx;
contourf(xx,yy,A)
hold on
delta=10;
quiver(xx(1:delta:end),yy(1:delta:end),x(1:delta:end,1:delta:end),y(1:delta:end,1:delta:end),0.5)
George
2014 年 5 月 23 日
wow, thank helped me a lot, indeed now the is near to what i am after
i got frustrated cause I followed the quiver of Matlab
may i ask how you detected the issue ?
thank you :)
Sara
2014 年 5 月 23 日
Tried your code with a delta of 2 instead of 20 and saw that the arrows where showing up in the bottom left corner of the image, i.e. matlab was simply using 1:1:nelem as coordinates not knowing any better.
Note, I added the 0.5 at the end of the quiver command so arrows don't touch. Please, modify that too so that the image will look like what you want.
George
2014 年 5 月 23 日
Thank you very much for the help
Sorry if i ask how you detected the mistake, but i wanted to know so I can learn :)
the 1:1 nelem never crossed my mind !!
thank you very much
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Vector Fields についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
