Which variables do I use to create a position/velocity waterfall plot?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have arrays x, y, and z that I am wanting to plot together on a surface/waterfall plot.
Where,
x=x-coordinate
y=y-coordinate
z=velocity
The size of each of the arrays are (1800x1 double).
I have created a meshgrid for x and y (1800x1800 double), however, my z array does not have enough columns for me to input it into the waterfall function.
How can I plot the 3 values together?
0 Commenti
Risposte (1)
Aman Banthia
il 5 Set 2023
Hi Amere,
I understand that you want the array “z” to be of the same size as that of “x” and “y”.
To do so please use the following approach inside your code.
Assuming you have already created the meshgrid for x and y.
x, y, and z are all column vectors of size (1800x1).
%Reshape z to match the size of the meshgrid
[X,Y] = meshgrid(x,y);
Z = reshape(z,size(X));
%Plot the surface/waterfall plot
waterfall(X,Y,Z);
xlabel('x-coordinate');
ylabel('y-coordinate');
zlabel('velocity');
title('Surface/Waterfall Plot');
You can refer to the below documentation to know more about the “Reshape” Function in MATLAB:
Hope that the above solution helps you.
Best Regards,
Aman Banthia
1 Commento
Dyuman Joshi
il 5 Set 2023
Z = reshape(z,size(X));
You are trying to reshape 1800x1 into 1800x1800, which is not possible.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D 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!