2D plot with 3D data

1 回表示 (過去 30 日間)
sim keng hei
sim keng hei 2011 年 3 月 10 日
hi,i'm newbie for Matlab.In my task,i have 256 number of x,y values. Each coordinate(x,y) has it own z value(intensity).The value of z was increase from left to right(x axis) but not increase uniformly.i would like to represent it by showing the z value in boundary,such as z=1-2,2,3,...is that possible?
Thanks for solving my problem.i can explain further if anything unclear above.
Regard. Sim.

回答 (3 件)

Jan
Jan 2011 年 3 月 10 日
You did not specify this, but I guess, that you want to create the output as a string.
% Test data (do they match your needs??):
z = floor(cumsum(rand(256, 256) * 2));
minz = min(z, 1);
maxz = max(z, 1);
minEQmax = (minz == maxz);
C = cell(1, 256);
for i = 1:256
if minEQmax(i)
C{i} = sprintf('%d,', minz(i));
else
C{i} = sprintf('%d-%d,', minz(i), maxz(i));
end
end
Str = ['z = ', cat(2, C{:})];
Str(end) = []; % Remove trailing comma
  1 件のコメント
sim keng hei
sim keng hei 2011 年 3 月 10 日
what i mean is i have 256 number of coordinate(points) on plot,each coordinate has its own intensity(z value).so, 1 would like to put the z value in category(divide by line/contour).The task is below:
http://www.scribd.com/doc/50446665/Doc1?secret_password=owuenlb7u9qol0dl9gi
I want to draw the line with 7,6,5,....
Can Matlab do that?
I really hope u can help me to solve it.i being searching the net for few days already.

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


Matt Tearle
Matt Tearle 2011 年 3 月 10 日
You want a contour plot? Given that it sounds like you have vectors of data:
% Make some fake data
x = rand(256,1)*4-2;
y = rand(256,1)*4-2;
z = x.*exp(-x.^2-y.^2);
% Put data onto a grid
[qx,qy] = meshgrid(linspace(min(x),max(x)),linspace(min(y),max(y)));
F = TriScatteredInterp(x,y,z);
qz = F(qx,qy);
% Make contour plot
contour(qx,qy,qz)
To get specific contour levels, you can do:
contour(...,<vector of levels>)

sim keng hei
sim keng hei 2011 年 3 月 11 日
Thank you.I already solved my problem by using the surface fitting tools.I manage to get the contour line to for my plot.

カテゴリ

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