Fit Gaussian into symbolic expression

7 visualizzazioni (ultimi 30 giorni)
Dhritishmam Sarmah
Dhritishmam Sarmah il 18 Dic 2018
Commentato: Walter Roberson il 21 Dic 2018
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 Commenti
Dhritishmam Sarmah
Dhritishmam Sarmah il 21 Dic 2018
Modificato: Dhritishmam Sarmah il 21 Dic 2018
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 il 21 Dic 2018
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 .

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by