フィルターのクリア

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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by