- #1
TaylorLL
- 8
- 0
Hello! I'm trying to plot a best fit for some generated EQ data and I'm having issues with nlinfit. My code is as follows and when I try to run it, I get an error referring to the anonymous function ("test"), nlinfit (from Matlab), and not having enough input arguments.
Both t and y are 121x1 column vectors.
Code:
%Test function
t = t';
y = y';
test = @(t0,k,phi) (t-t0).*sin(k.*(t-t0)+phi).*(t>=t0)...
+ (t0).*sin(k.*t0 +phi).*(t< t0);
%Need to guess t0 - arrival time, k - wavenumber, phi - offset
guess = [6 3 0];
%nlinfit
coef_inv = nlinfit(t,y,test,guess);
Both t and y are 121x1 column vectors.
Last edited: