How to plot implicit function with conditions?

7 ビュー (過去 30 日間)
Abir Ghosh
Abir Ghosh 2022 年 7 月 10 日
編集済み: Torsten 2022 年 7 月 11 日
I need to plot a function / surface of the form f(x,y,z)=0
But, I also need to put some constraints like
-3.14< $\sqrt{x+y}$ <3.14
How can i achieve this?

回答 (2 件)

Torsten
Torsten 2022 年 7 月 10 日
編集済み: Torsten 2022 年 7 月 10 日
  4 件のコメント
Torsten
Torsten 2022 年 7 月 10 日
Here is an example:
fimplicit(@fun)
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
function values = fun(x,y)
values = NaN(size(x));
values(x+y<0) = x.^2+y.^2-1.0;
end
Abir Ghosh
Abir Ghosh 2022 年 7 月 11 日
My function is actually in cylindrical polar coordinates:
f(R,theta, z) = (tan(r+z)+tan(z-r)) - (tan(r+z)-tan(z-r))cos(theta)
and my domain for plot is
-pi<r+z<pi and -pi<z-r<pi

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


Torsten
Torsten 2022 年 7 月 11 日
編集済み: Torsten 2022 年 7 月 11 日
Doesn't look that nice ...
fimplicit3(@fun,[-5 5 -5 5 -5 5])
function values = fun(x,y,z)
[theta,r] = cart2pol(x,y);
%r = sqrt(x.^2+y.^2);
%theta = atan2(y,x);
values = NaN(size(x));
for i=1:numel(x)
if abs(z(i)+r(i)) < pi && abs(z(i)-r(i)) < pi
values(i) = (tan(z(i)+r(i))+tan(z(i)-r(i))) - (tan(z(i)+r(i))-tan(z(i)-r(i))).*cos(theta(i));
end
end
end

カテゴリ

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