Fitting a convolution and indexing anonymous functions

4 ビュー (過去 30 日間)
thatguy14
thatguy14 2015 年 11 月 13 日
編集済み: thatguy14 2015 年 11 月 13 日
Hello, I am trying to fit something that requires a convolution.
With matlab, the discrete convolution means that it is only valid for the time over which the two functions are defined (matlab evaluates the convolution past this). As such, I am only interested in the part of the convolution that my functions are defined over. When I usually do my convolution, this is how:
x = 1:someNumber; numberOfElements = length(x);
newFunc = conv(func1,func2) newFunc = newFunc(1:numberOfElements)
where func1 and func 2 are defined over x. Using the 'same' property doesn't work.
The problem lies now that I need to do fitting using the convolution i.e.,
model = @(a, b, c, x) conv(func1(a,b,c,x),func2(a,b,c,x))
outputFit = fit(x,y,model) but not I need some way to tell matlab that I only want certain points from the convolution.
Any help?
Edit: I should mention that I tried to avoid the convolution entirely by changing my convolution to an integral.
If function 2 is exp(a(t-t')/b)
and the convoltuon is
integral from (0 to t) of func1(t)*exp(a(t-t')/b)dt' - you can factor out the t and just have an integral from 0 to t (but its every t in the array i.e., 0 to t1 0 to t2 0 to t3...
I did this using arrayfun
kineticModel = @(ve,Ktrans,shift,x) Ktrans.*exp(-Ktrans.*(x-shift)./ve).*arrayfun(@(x) integral(@(x) Cpt(x,shift).*exp(Ktrans.*(x-shift)./ve),shift,x),x);
but for some reason when I plot the resulting kineticModel fit and then plug those values back into a convolution (to see if they are the same) they aren't, even when I have normalized the convolution by the spacing.

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by