From: Piter_ on 16 Nov 2009 13:29 Hi all. I have one question about CurveFitting toolbox. Lest say I have 3 datasets. D1= A1_1exp(k1*t)+A2_1*exp(k2*t)+A3_1*exp(k3*t)+C1 D2= A1_2exp(k1*t)+A2_2*exp(k2*t)+A3_2*exp(k3*t)+C2 D3= A1_3exp(k1*t)+A2_3*exp(k2*t)+A3_3*exp(k3*t)+C3 Is there any way to fit it using curve fitting toolbox. Thanks Petro P.S. So far I did it using matrix based fit and fminsearch but I wanted to apply curve fitting toolbox there: function [ssq par] = exp_mb_ls(par,t,v,s) [ro co]=size(t); len=ro; [ro co]=size(par); F=ones(len, co+1); F(:,1:co)=(ones(size(t))*par(1,:).*exp(-ones(size(t))*par(2,:).*(t*ones (1,co)))); Ht=pinv(F)*v; v_star=F*Ht; resid=v-v_star; pinv(F); ssq=norm(resid*s); And fitfing using exp_mb_ls function par0=[0.5 0.5 0.2 0.1;... 10000 5000 80 50;]... %matrix based fit of v vectors par_svd=fminsearch('exp_mb_ls',par0,[],t,v(:,1:3),s(1:3,1:3)); %generating fitted v vectors [ro co]=size(par_svd); F=ones(21,co+1); for i=1:co F(:,i)=exp(-t*par_svd(2,i))*par_svd(1,i); end Ht=pinv(F)*v(:,1:3); vfit=F*Ht; figure plot(t,[v(:,1:3)],'o',t,vfit,'*') %legend('v','v fit') grid on title('svd based fit of v(:,1:3)') set(gca,'xscale','log') grid on
|
Pages: 1 Prev: FFT / IFFT time shift problem Next: New solver in Simulink |