MATLAB MATLAB: Fitting a convolution

  • Thread starter Niles
  • Start date
1,868
0
Hi

I have the following piece of code:

Code:
dataX = -4:1:4;
dataY = [0 -1 -10 -40 -55 10 40 10 1];

figure(1)
plot(dataX, dataY, '*');

x = -2:0.01:2;
plot(-4:0.01:4, 1*conv(exp(-x).*heaviside(x),sin(x)), dataX, dataY, '*')

mdl = @(a, x)(a(1)*conv(exp(-x).*heaviside(x),sin(x)));

par=[1];
[fitted_par, r, J, cov, mse] = nlinfit(dataX, dataY, mdl, par);
What I am trying to do is to fit the function (a convolution) to the data set. However, I get an error due to vector size mismatch. I'm not sure what is going on here: The fitting routine should not care about how many data points I have?

Regards, Niels.
 

Want to reply to this thread?

"MATLAB: Fitting a convolution" You must log in or register to reply here.

Related Threads for: MATLAB: Fitting a convolution

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top