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
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
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 个)
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'}])
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!