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

조회 수: 1 (최근 30일)
Amere
Amere 2022년 6월 21일
댓글: Dyuman Joshi 2023년 9월 5일
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?

답변 (1개)

Aman Banthia
Aman Banthia 2023년 9월 5일
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
Dyuman Joshi
Dyuman Joshi 2023년 9월 5일
Z = reshape(z,size(X));
You are trying to reshape 1800x1 into 1800x1800, which is not possible.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by