MATLAB Answers

How do you use contour if you only know f(x,y,z) but not z(x,y)?

5 ビュー (過去 30 日間)
Richard Yan
Richard Yan 2021 年 9 月 13 日
コメント済み: Richard Yan 2021 年 9 月 13 日
The question has given the function f(x,y,z), domain, range of f(x,y,z) and f(x,y,z) = 0. Then it asks me to use contour to plot the values of x and y for different values of z. I browsed how to use contour but the website only shows that if you know function z(x,y), so I tried to solve z in terms of x and y but I think it did not work for the given f(x,y,z).
Here is the function:
2*cot(x)*((z^2*sin(x)^2-1)/(z^2*(1.4+cos(2*x))+2))-tan(y)=0
Thank you!

採用された回答

darova
darova 2021 年 9 月 13 日
[x,y,z] = meshgrid(-10:10); % x y z range
f = x + y.^2 - z.^2; % function f(x,y,z)
[f,v] = isosurface(x,y,z,f,0); % extract faces and vertices
% extract points
x0 = v(:,1);
y0 = v(:,2);
z0 = v(:,3);
ii = z0 > 0; % build contour for z > 0 only
[x1,y1] = meshgrid(-10:10); % new range for contour
z1 = griddata(x0(ii),y0(ii),z0(ii),x1,y1); % interpolate to create matrix
contour3(x1,y1,z1,'linewidth',2)
P1.faces = f;
P1.vertices = v;
P1.facecolor = 'r';
P1.edgecolor = 'none';
patch(P1)
light
  1 件のコメント
Richard Yan
Richard Yan 2021 年 9 月 13 日
Thank you very much! This is very helpful! Hope you have a wonderful day!

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

その他の回答 (0 件)

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by