Surf plot for three independent matrices of 1x360

2 Ansichten (letzte 30 Tage)
Anisha Varughese
Anisha Varughese am 8 Aug. 2019
Kommentiert: Star Strider am 9 Aug. 2019
Hey , I have three matrices of equal dimensions and i want to make a surf plot for it. Can someone help me with it. Basically X,Y are coordinates of the position and Z is the value at that Point. Thanks in advance for everyone who tries to help.

Akzeptierte Antwort

Star Strider
Star Strider am 8 Aug. 2019
You have one matrix of three (1x360) row vectors. If your data are gridded, simply use the reshape function on each row vector to create appropriate matrices from them.
If your data are not gridded (random), use the griddata function (or similar functions) to create appropriate matrices for the surf plot.
One easy way to see if your data are gridded is to plkot them using the stem3 function. If they are gridded, that will be obvious.
  10 Kommentare
Anisha Varughese
Anisha Varughese am 9 Aug. 2019
X and Y are coordinates and Z is velocity at that position. The files are too big to attach. sorry.
Star Strider
Star Strider am 9 Aug. 2019
X and Y are coordinates and Z is velocity at that position.
That means that your two independent variable vectors are ‘X’ and ‘Y’, and your dependent variable vector is ‘Z’. My original Answer using griddata should work with your vectors.
A (3x360) matrix should not be too large to attach here.
Try this with your data:
X = rand(1, 360); % Create Vector
Y = rand(1, 360); % Create Vector
Z = rand(1, 360); % Create Vector
N = 50; % Grid Matrix Size
xv = linspace(min(X), max(X), N); % ‘X’ Vector To Define Interpolation Matrix
yv = linspace(min(Y), max(Y), N); % ‘Y’ Vector To Define Interpolation Matrix
[Xm,Ym] = meshgrid(xv, yv); % Create Interpolation Matrices
Zm = griddata(X, Y, Z, Xm, Ym); % Interpolate Vectors To Grids
figure
surfc(Xm, Ym, Zm)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
That should work with your vectors without further modification. Much depends on the vectors themselves, of course, and I do not have them to work with.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by