Which variables do I use to create a position/velocity waterfall plot?

1 view (last 30 days)
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?

Answers (1)

Aman Banthia
Aman Banthia on 5 Sep 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

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!