2D plot with 3D data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (3)
Jan
am 10 Mär. 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
Matt Tearle
am 10 Mär. 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>)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!