Azzera filtri
Azzera filtri

Using surf to compare three vectors

2 visualizzazioni (ultimi 30 giorni)
balsip
balsip il 3 Lug 2017
Commentato: balsip il 9 Lug 2017
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 Commento
John D'Errico
John D'Errico il 3 Lug 2017
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?

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 4 Lug 2017
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 Commento
balsip
balsip il 9 Lug 2017
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.

Accedi per commentare.

Più risposte (1)

KSSV
KSSV il 4 Lug 2017
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 Commento
balsip
balsip il 4 Lug 2017
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!).

Accedi per commentare.

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by