Azzera filtri
Azzera filtri

how to express a formula for modelFun fo nlinfit

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Star Strider
Star Strider il 3 Apr 2014
Modificato: Star Strider il 3 Apr 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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by