Plotting a 2D Contour from data (A variable with its XY coordinates)

12 ビュー (過去 30 日間)
Peter
Peter 2014 年 12 月 29 日
コメント済み: Sean de Wolski 2014 年 12 月 29 日
Hello!
I need to plot a 2D Contour form data. I have a variable called "Intensity" with 224x1 values and I have a variable called "XYAxis" with the corresponding coordinates of this Intensity (224 points (X,Y)).
What i want to do is to plot both variables, to have a contour2D with the distribution of the Intensity among the points analized (each value of Intensity corresponds to one point(X,Y).
I have tried:
Contour (XYAxis,Intensity);
But it only displays an empty plot and the axis are not those i desire (i want the contour to be like scattered).
Any idea? Maybe TriScatteredInterp()?? but i need the contour to be 2D
Thanks in advanced
  2 件のコメント
Sean de Wolski
Sean de Wolski 2014 年 12 月 29 日
Could you provide a small set of sample data?
Peter
Peter 2014 年 12 月 29 日
Sure,
For example, I have one variable called " XYAxis " (224x2 double) this way (1º column is X and 2º Column is Y):
0 0
0 5
5 10
10 20
20 30
... until 224 points
And I have another variable called " Intensity " like this:
0.5
0.8
0.9
0.10
0.11
...
until 224 values
So each value of "Intensity" corresponds with one value of "XYAxis" And i want to plot it with a contour 2d. Thanks

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

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 12 月 29 日
編集済み: Sean de Wolski 2014 年 12 月 29 日
% Synthetic Data
xy = rand(20,2);
intensity = rand(20,1);
% Interpolate to grid
interpolant = scatteredInterpolant(xy(:,1),xy(:,2),intensity);
% Grid
[xx,yy] = meshgrid(linspace(0,1,10)); % replace, 0 1, 10 with range of your values
% Interpolate
intensity_interp = interpolant(xx,yy);
contourf(xx,yy,intensity_interp)
You'll have to interpolate it to a grid and then call contour.
  9 件のコメント
Peter
Peter 2014 年 12 月 29 日
編集済み: Peter 2014 年 12 月 29 日
I mean "automatically", with the names of the axis on it and a legend
Sean de Wolski
Sean de Wolski 2014 年 12 月 29 日
xlabel('whatever x is')
ylabel('whatever y is')
filename = ['file' num2str(1) '.png'] % replace 1 with whatever you want automatically created.
saveas(gcf,filename)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by