How to find the solution of inverse function ?
조회 수: 26 (최근 30일)
이전 댓글 표시
Hello, I have some question for solving matlab.
if x = [1 2 3 4 5 6 7] and y = [3.6 1.8 1.2 0.9 0.72 1.5 0.51429]
I want to find f(x) = 1.7 and inverse of f(1.7) (quadratic form)
The code I implemented is
>> x = [1 2 3 4 5 6 7]; y = [3.6 1.8 1.2 0.9 0.72 1.5 0.51429];
>> p = polyfit(x,y,2);
>> syms x;
>> fx = p(1)*x^2 + p(2)*x + p(3);
>> gx = finverse(fx,x);
>> gx(1.7) // error! (The index exceeds the number of array elements (1).)
Why does gx(1.7) throw an error? What should I do for getting gx(1.7) ?
댓글 수: 0
채택된 답변
Stephan
2020년 11월 24일
x = [1 2 3 4 5 6 7];
y = [3.6 1.8 1.2 0.9 0.72 1.5 0.51429];
p = polyfit(x,y,2)
syms x
fx(x) = poly2sym(p)
gx(x) = finverse(fx)
sol = gx(1.7)
sol_num = double(sol)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!