Using surf to compare three vectors

2 次查看(过去 30 天)
I'd like to compare three vectors graphically, and I think surf is the function to use.
In exploring surf, I can't wrap my head around how to implement meshgrid. The variables I want to compare are all vectors of the same length, yet Z needs to be a matrix according to the documentation, and meshgrid is somehow involved.
X: 7627x1, range: 420 to 480
Y: 7627x1, range: -30 to -8
Z: 7627x1, range: 0.8 to 4.2
In all of the examples on the surf documentation page, the Z-axis is always symmetrical about 0. Can you use surf where the Z-axis minimum is 0?
If surf isn't what I want to use to do this, please point me in the right direction. I've also seen rectangular colormaps using filled in color gradients (i.e., not points or lines) comparing X vs. Y vs. Z (represented by color). Obviously, there's some interpolation happening in both this 2-d colormap as well as surf.
As a sample, how does one produce something like this sample, which is comparing X vs. Y vs. Z (denoted with a color ramp).
Thanks, everybody. As always, the help is much appreciated.
  1 个评论
John D'Errico
John D'Errico 2017-7-3
Nope. Surf is NOT the tool to use here. Surf is not a tool used to compare vectors graphically. In fact, I don't even know what you mean by that.
There is NO requirement with surf that the z axis have any special limits.
If you want to compare three vectors, just use plot. WTP?
Surf is used to plot a surface. Is that what you really want to do?

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2017-7-4
Just make up a 2-D array with the number of rows and columns you want, then assign the z values to it. Then display it. Like, is this what you want?
% X: 7627x1, range: 420 to 480
% Y: 7627x1, range: -30 to -8
% Z: 7627x1, range: 0.8 to 4.2
columns = 7627; % X
rows = 7627; % Y
indexedimage = zeros(rows, columns); % Zero image, or...
indexedimage = 0.8 + (4.2-0.8)*rand(rows, columns); % random image
xData = linspace(420, 480, columns);
yData = linspace(-30, -8, rows);
imshow(mat2gray(indexedimage), 'XData', xData, 'YData', yData);
colormap(gca, hsv(256));
colorbar;
  1 个评论
balsip
balsip 2017-7-9
That's great, Image Analyst. Thank you. It'll achieve the type of plot I was looking for. It turns out that what I originally showed above is best suited for a certain type of data beyond just having an X, Y, and Z. Great to have in the arsenal, though.

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2017-7-4
x = linspace(420,480,7627) ;
y = linspace(-30,-8,7627) ;
z = linspace(0.8,4.2,7627) ;
figure
hold on
plot(x,'r') ;
plot(y,'b') ;
plot(z,'g') ;
legend([{'X'},{'Y'},{'Z'}])
  1 个评论
balsip
balsip 2017-7-4
Thanks for the input, KSSV. While this is, indeed, a solution to what I posed above, I guess I was looking for a fancier option.
I'm going to edit my original post with an example of what I'm looking to produce (which I should have done in the first place!).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by