Fit Gaussian into symbolic expression

조회 수: 7 (최근 30일)
Dhritishmam Sarmah
Dhritishmam Sarmah 2018년 12월 18일
댓글: Walter Roberson 2018년 12월 21일
I have a symbolic expression which contains very complex terms. I wish to fit this expression into a Gaussian Distribution.
The fit function takes only arrays as arguments. So i tried to find the data points of my symbolic expression using subs, but is there a better way to fit the expression directly into a gaussian?
EDIT: Not only Gaussian but solution for any other fittype such as 'rat', 'poly', etc, is happily accepted.
  댓글 수: 5
Dhritishmam Sarmah
Dhritishmam Sarmah 2018년 12월 21일
편집: Dhritishmam Sarmah 2018년 12월 21일
Let me show, what i have been doing until now;
syms s
H % my symbolic expression. I know the terms in H since i solved it on pen and paper.
% also used fplot to see its plot.
x= -5:1/100:5;
y = double(subs(H, s, x)); %time consuming step;
f1 = fit(x', y', 'rat44'); % example fittype, can also have selfdefinded type
% f1 =
% General model Rat44:
% f1(x) = (p1*x^4 + p2*x^3 + p3*x^2 + p4*x + p5) /
% (x^4 + q1*x^3 + q2*x^2 + q3*x + q4)
H_fit = (f1.p1*s^4 + f1.p2*s^3 + f1.p3*s^2 + f1.p4*s + f1.p5)/ ...
(s^4 + f1.q1*s^3 + f1.q2*s^2 + f1.q3*s + f1.q4);
For different fittypes i have to write the last line separately for different expression. Is there a better way?
Walter Roberson
Walter Roberson 2018년 12월 21일
extract the model formula from the fit object and str2sym it. extract the parameter names and values and subs()
However in practice you might be able to just feval() the fit object at particular locations or plot the fit object .

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by