Surf plot for three independent matrices of 1x360
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Anisha Varughese
il 8 Ago 2019
Commentato: Star Strider
il 9 Ago 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.
0 Commenti
Risposta accettata
Star Strider
il 8 Ago 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 Commenti
Star Strider
il 9 Ago 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots 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!