Effacer les filtres
Effacer les filtres

how to express a formula for modelFun fo nlinfit

2 vues (au cours des 30 derniers jours)
Donatas
Donatas le 3 Avr 2014
Hello, guys,
I have the formula (convolution):
where
and C is a matrix 1x40 and t is also a matrix of 1x40.
I want to use the first formula for non-linear least square fit (nlinfit), but I don't know how to write modelFun to express this formula, where MTT is a parameter, which I need to estimate.
Thanks for a reply!
Donatas

Réponse acceptée

Star Strider
Star Strider le 3 Avr 2014
Modifié(e) : Star Strider le 3 Avr 2014
I made several guesses as to what you are doing, but this seems to work:
% Create data:
t = linspace(0, 1, 40);
C = t;
% y = conv(t,exp(-t),'same');
y = conv(exp(-t/7),t);
% Objective function for curve fit
% w = @(P,t) conv(C, exp(-t/P),'same');
w = @(P,t) conv(C, exp(-t/P));
xv = 0:length(y)-1;
B = nlinfit(t, y, w, 1)
yp = w(B,t);
figure(1)
plot(xv, y, 'xb')
hold on
plot(xv, w(B,t), '-r')
hold off
grid
Note that there are 'full', 'same' and 'valid' options with the conv function. Use the one that most closely suits your needs.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by