Hi(adsbygoogle = window.adsbygoogle || []).push({});

I have the following piece of code:

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?Code (Text):

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);

Regards, Niels.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB: Fitting a convolution

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - MATLAB Fitting convolution | Date |
---|---|

Matlab Matlab Power Fit on Graph-Codes | Apr 23, 2017 |

Matlab Displaying the Fit Equation On graph. | Apr 2, 2017 |

Matlab Spline Fit | Dec 5, 2015 |

Fit with implicit nonlinear function - Matlab | Oct 19, 2015 |

**Physics Forums - The Fusion of Science and Community**