Which variables do I use to create a position/velocity waterfall plot?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
2023년 9월 5일
Z = reshape(z,size(X));
You are trying to reshape 1800x1 into 1800x1800, which is not possible.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!