Encounter an error while using fimplicit?

How to plot the following equation on matlab by using fimplicit?
(x-x0).*conj((x-x0))+(y-y0).^2=r^2
close all;
r=1./2;
x0=0;
y0=1./2;
syms x y
fimplicit((x-x0).*conj((x-x0))+(y-y0).^2-r^2)
axis equal
Matlab shows
'Undefined function or variable 'fimplicit'.'

 採用された回答

Star Strider
Star Strider 2020 年 4 月 16 日

0 投票

The fimplicit function was introduced in R2016b.
Use the contour function instead:
r=1./2;
x0=0;
y0=1./2;
f = @(x,y) (x-x0).*conj((x-x0))+(y-y0).^2-r^2;
xv = linspace(x0-r, x0+r, 25);
yv = linspace(y0-r, y0+r, 25);
[X,Y] = ndgrid(xv,yv);
figure
contour(X,Y,f(X,Y), [0 0])
grid
axis equal
.

6 件のコメント

Wajahat
Wajahat 2020 年 4 月 16 日
@ Star Strider, how can we fill the color inside the circle like this
Star Strider
Star Strider 2020 年 4 月 16 日
Add a patch call:
figure
hc = contour(X,Y,f(X,Y), [0 0]);
hold on
patch(hc(1,2:end), hc(2,2:end), [0.4 0.2 0.9], 'FaceAlpha',0.3)
hold off
grid
axis equal
Experiment with different colours (the ‘[0.4 0.2 0.9]’ vector) to get the result you want.
Wajahat
Wajahat 2020 年 4 月 16 日
@ Star Strider, but when we change the sign, it shows the hyperbolic plot
r=1./2;
x0=0;
y0=1./2;
f = @(x,y) -(x-x0).*conj((x-x0))+(y+y0).^2-r^2;
xv = linspace(x0-r, x0+r, 25);
yv = linspace(y0-r, y0+r, 25);
[X,Y] = ndgrid(xv,yv);
figure
hc = contour(X,Y,f(X,Y), [0 0]);
hold on
patch(hc(1,2:end), hc(2,2:end), [0.8 0.1 0.9], 'FaceAlpha',0.3)
hold off
grid off
axis equal
But I need like this
Star Strider
Star Strider 2020 年 4 月 16 日
This is a different problem.
With this function:
f = @(x,y) -(x-x0).*conj((x-x0))+(y+y0).^2-r^2;
the patch call changes to:
patch([hc(1,2:end) fliplr(hc(1,2:end))], [hc(2,2:end) ones(size(hc(1,2:end)))*max(ylim)], [0.4 0.2 0.9], 'FaceAlpha',0.3)
The rest of the code is not changed.
Wajahat
Wajahat 2020 年 4 月 16 日
I got this
which is not same as the previous attached hyperboic image
Star Strider
Star Strider 2020 年 4 月 16 日
Adjust the limits of ‘xv’ (and perhaps also ‘yv’) to match the figure you want.
For example:
xv = linspace(-1, 1, 25);
You may need to change the parameters in the ‘f’ function to exactly reproduce the figure you posted.

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2020 年 4 月 16 日

コメント済み:

2020 年 4 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by