フィルターのクリア

Plot cross section at particular value of x for mesh(x,y,z).

9 ビュー (過去 30 日間)
V Patel
V Patel 2016 年 4 月 12 日
コメント済み: Alka Panda 2021 年 2 月 26 日
I have a mesh plot mesh(x,y,z) where x,y and z are having 100 by 100 values. Now I want a cross section plot at a particular value of x. How to do this?

採用された回答

Star Strider
Star Strider 2016 年 4 月 12 日
You can easily adapt this to your data. I chose different lengths of the ‘x’ and ‘y’ vectors to demonstrate and trace the indexing of the matrices:
x = linspace(5, 10, 80); % Create Data
y = linspace(1, 5, 50); % Create Data
[X,Y] = meshgrid(x,y); % Create Data
Z = sin(X.^2) - cos(Y.^2); % Create Data
figure(1)
surf(X, Y, Z) % Surface Plot
grid on
X_idx = find(x >= 7.5, 1, 'first'); % Find Desired ‘X’ Value
figure(2)
plot(Y(:,X_idx), Z(:,X_idx)) % Plot At Desired ‘X’ Value
grid
  2 件のコメント
Denise Janer
Denise Janer 2021 年 1 月 9 日
Hi may I ask why you defined Z using that formula?
What if I have a mesh (x, y, z) where z is depth data? How can I make a cross section at any other points in the x and y axis?
Thanks.
Alka Panda
Alka Panda 2021 年 2 月 26 日
It was just an example, you can adapt Z to a function of your choice

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by