フィルターのクリア

plot a surface for g-f=0

1 回表示 (過去 30 日間)
M
M 2022 年 6 月 5 日
コメント済み: Star Strider 2022 年 6 月 6 日
Hi, would you mind telling me how can I plot g-f=0 as a surface.
f=0.07.*z.^2./(0.09+z.^2) and g=0.003+0.01.*(42./(42+(y-z).^4))
Thanks in advance for any help.

採用された回答

Star Strider
Star Strider 2022 年 6 月 5 日
That is challenging, however it will work with certain restrictions on the matrix dimensions (i.e. they must both be the same sizes) —
f = @(z) 0.07.*z.^2./(0.09+z.^2);
g = @(y,z) 0.003+0.01.*(42./(42+(y-z).^4));
N = 25;
y = linspace(-10, 10, N);
z = linspace(-10, 10, N);
[Y,Z] = ndgrid(y,z);
figure
surf(Y,Z,f(Z))
colormap(turbo)
figure
surf(Y,Z,g(Y,Z))
colormap(turbo)
figure
surf(Y,Z,g(Y,Z)-f(Z))
hold on
contour3(Y,Z,g(Y,Z)-f(Z), [0 0], '-r', 'LineWidth',2) % Plot Contour At 0
hold off
colormap(turbo)
.
  4 件のコメント
Paul
Paul 2022 年 6 月 6 日
Why use ndgrid() here and not meshgrid()? Doesn't surf expect the first two arguments to be in meshgrid() format?
Star Strider
Star Strider 2022 年 6 月 6 日
Either work, although the outputs are different. Some functions require meshgrid and others require ndgrid.

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

その他の回答 (1 件)

Torsten
Torsten 2022 年 6 月 5 日
編集済み: Torsten 2022 年 6 月 5 日
The "surface" f-g = 0 is a one-dimensional manifold in the y/z - plane and you get the corresponding curves using the "fimplicit" command:
fimplicit(@(y,z)0.07.*z.^2./(0.09+z.^2)-(0.003+0.01.*(42./(42+(y-z).^4))))

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by