I have been trying to fit some data with a model for some time now and am getting fairly close. In origin pro the fit seems to work ok and I get reasonable parameters back albeit the residuals are a little funny. Unfortunately in Matlab the fit is not so good. Could I send some one my code my function and some data to take a look at?
Oh and also there are imaginary numbers!
clear all; close all close all hidden A = uiimport; clear xdata; clear ydata; xdata = A.data(:,1); ydata = A.data(:,2); Vg = xdata; Id = abs(ydata); x0 = [8.6E-10;1.7;0.8;5E6]; options = optimset('Display','iter',... 'TolFun',1E-100,'TolX',1E-100,'MaxIter',1000); [beta,resid,J,COVB,mse] = nlinfit(Vg,Id,@RcFun,[x0],options); [ci se] = nlparci(real(beta),resid,'covar',COVB); Id_new = ((((real(beta(1))*((Vg-real(beta(2))).^(real(beta(3))+1))).^(-1))+real(beta(4))).^(-1)); plot(Vg,Id_new,'r',Vg,Id,'o'); hold on; plot(Vg,resid,'+'); function F = Rcfun(a,Vg) K = real(a(1)); V = real(a(2)); b = real(a(3)); R = real(a(4));F = (((K.*(Vg-V).^(b+1)).^(-1))+R).^(-1); end
Data
A B0 3.03E-121 1.5E-132 1.58E-123 2.81E-124 2.55E-125 2.31E-126 4.13E-127 2.89E-128 4.99E-129 6.38E-1210 1.068E-1111 1.96E-1112 5.343E-1113 5.405E-1114 5.347E-1115 5.142E-1116 2.4139E-1017 7.4428E-1018 1.5752E-919 2.7328E-920 4.3347E-921 6.5506E-922 9.5258E-923 1.31356E-824 1.72672E-825 2.17876E-826 2.66302E-827 3.18252E-828 3.7101E-829 4.23594E-830 4.78078E-831 5.32604E-832 5.86136E-833 6.39262E-834 6.93234E-835 7.47466E-836 8.01152E-837 8.54398E-838 9.08214E-839 9.62598E-840 1.0184E-741 1.074E-742 1.1322E-743 1.1876E-744 1.2432E-745 1.299E-746 1.3534E-747 1.4062E-748 1.4596E-749 1.5096E-750 1.558E-751 1.6118E-752 1.6616E-753 1.7064E-754 1.7546E-755 1.7946E-756 1.8402E-757 1.8776E-758 1.9138E-759 1.9584E-760 1.9992E-7
Best Answer