2D plot with 3D data
Afficher commentaires plus anciens
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.
Réponses (3)
Jan
le 10 Mar 2011
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 commentaire
sim keng hei
le 10 Mar 2011
Matt Tearle
le 10 Mar 2011
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
le 11 Mar 2011
0 votes
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!