Hi all - I hope someone can help me.
I have three data sets:
  • wind speed
  • wind direction
  • error.
What I'd like to do is to create a contour plot that shows values of error in terms of the wind speed and direction - in so far that the diagram will illustrate where the greater values of error are with respect to both wind speeds and direction. Can any one help??

1 件のコメント

bym
bym 2012 年 2 月 12 日
perhaps you will want to investigate meshgrid()

サインインしてコメントする。

回答 (3 件)

the cyclist
the cyclist 2012 年 2 月 10 日

0 投票

Use the contour() function. Type "doc contour" into MATLAB for details.

5 件のコメント

Keith
Keith 2012 年 2 月 12 日
Thanks for that cyclist - but I have been trying to get that function to work.
I have three data sets in a text file I'd like to plot the third set (the error set) against speed and direction. When I try to employ contour() it states that Z must be a matrix at least 2x2 whereas.
What I've been playing around is as follows:
load Error_No_Filter.txt
X=Error_No_Filter(:,1) % Wind Speed
X=Error_No_Filter(:,2) % Wind Direction
Z=Error_No_Filter(:,3) % error
[C,h] = contour(X,Y,Z);
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
colormap cool
the cyclist
the cyclist 2012 年 2 月 13 日
There are different syntaxes for calling contour(), but in general it is expecting the Z input to be a matrix, with one value for each possible (x,y) combination. Here is a very simple prototype for the syntax:
x = 1:5;
y = (1:10)';
z = bsxfun(@times,y,x)
contour(x,y,z)
If your wind speeds and directions are on a regular grid, then you'll just need to reshape your Z values accordingly. If not, you might need to use TriScatteredInterp() to create the regular grid that contour() is expecting.
Keith
Keith 2012 年 2 月 13 日
Thanks again cyclist - I'll give that a go....
Keith
Keith 2012 年 2 月 14 日
Hi cyclist - that appears to work - although to be honest, it doesn't produce the contoured illustration I desire. The code::
load Error_No_Filter.txt
X=Error_No_Filter(:,1)
Y=Error_No_Filter(:,2)
Z=Error_No_Filter(:,3)
F.Method = 'nearest';
F = TriScatteredInterp(X, Y, Z);
x_axis = 0:1:15;
y_axis = 0:10:360;
[qx,qy] = meshgrid(x_axis,y_axis);
qz = F(qx,qy);
mesh(qx,qy,qz); hold on; contour3(X,Y,Z);
xlabel('Wind Speed [m/s]', 'fontweight','b'), ylabel('Wind Direction [deg]','fontweight','b')
zlabel('error', 'fontweight','b')
title('Interpolated error in terms of wind speed & direction', 'fontweight','b');
From the above, do you have any suggestions that can facilitate turning the above into a contour illlustration that also illustrates the values of the associated cotours?
Thanks,
KEith
the cyclist
the cyclist 2012 年 2 月 14 日
I think what you want is the colorbar command. Just run that command after your code.

サインインしてコメントする。

Image Analyst
Image Analyst 2012 年 2 月 12 日

0 投票

Why not use TriScatteredInterp() to turn your set of (x,y,z) triplets into an image, and display it as an image? That would probably be an insightful visualization and allow you to see patterns. Or you can do a surface plot. There's a nice demo for that in the help for TriScatteredInterp().
Sean de Wolski
Sean de Wolski 2012 年 2 月 14 日

0 投票

It sounds like you might be interested in a streamtube or streamribbon plot.
doc streamribbon
doc streamtube

カテゴリ

ヘルプ センター および File Exchange で Contour Plots についてさらに検索

質問済み:

2012 年 2 月 10 日

編集済み:

2013 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by