lsqcurvefit help: Error using asset. FUN must have two input arguments.
Show older comments
I'm trying to work through a curve fitting problem and I haven't been able to resolve the following coding error. Unfortunately, I haven't done much curve fitting as of yet, so any help is greatly appreciated!
PV = readtable('clean_data.csv');
NV = readtable('noisy_data.csv');
% PV is clean
lambda_p = table2array(PV(:,1));
I_p = table2array(PV(:,2));
% NV is noisy
lambda_n = table2array(NV(:,1));
k_n = lambda_n./(2*pi);
I_n = table2array(NV(:,2));
w_e = 2.8e-8;
% Curve fitting with v_hat in Fourier space
v_hat_p = abs(fft(I_p));
k_p = lambda_p./(2*pi);
v_hat = @(A_v,w_g,w_l) A_v.*exp(-(w_g.^2*k_p.^2)/(16*log(2)) - (w_l.*abs(k_p))./2);
A_v = 100; w_g = 0.01; w_l = 0.01; % Initial guesses
x0 = [A_v, w_g, w_l]; % initial guesses
[x_fit,y_fit] = lsqcurvefit(v_hat,x0,k_p,v_hat_p);
Error using assert
FUN must have two input arguments.
Error in lsqcurvefit (line 229)
assert(numberInput == 2, message('optimlib:lsqcurvefit:NotEnoughInputArg'));
Error in myfilename (line 29)
[x_fit,y_fit] = lsqcurvefit(v_hat,x0,k_p,v_hat_p);
Accepted Answer
More Answers (0)
Categories
Find more on Nonlinear Least Squares (Curve Fitting) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!