explict (pointwise) function from numerical solution to implicit equation

15 ビュー (過去 30 日間)
Laurence Kranich
Laurence Kranich 2020 年 6 月 5 日
コメント済み: Ameer Hamza 2020 年 6 月 11 日
I can plot the numerical solutions to a complicated expression f(x,y)=0 over intervals for x and y using fimplicit(f,interval). However, how do I then define/specify an explicit relation y=g(x) pointwise using the numerical values computed from f(x,y)=0 for use in a separate expression? (There is a functional relation.)

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 6 日
編集済み: Ameer Hamza 2020 年 6 月 6 日
Try interp1 to create an explicit relation for 'y' in term of 'x' using the datapoints from fimplicit
f = @(x, y) y - x.^2;
fp = fimplicit(f, [-2 2 0 10]);
x = fp.XData;
y = fp.YData;
g = @(xq) interp1(x, y, xq);
Then run
>> g(1)
ans =
1.0002
>> g(0.5)
ans =
0.2501
Alternate solution:
Use fsolve() directly. The advantage is that you can control the spacing of x-points
f = @(x, y) y - x.^2;
x = -2:0.01:2;
y = fsolve(@(y) f(x, y), rand(size(x)));
g = @(xq) interp1(x, y, xq);
  5 件のコメント
Laurence Kranich
Laurence Kranich 2020 年 6 月 11 日
That worked. Thanks again!!
Ameer Hamza
Ameer Hamza 2020 年 6 月 11 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by