Having trouble with a global fit to several curves of intensity vs. frequency to extract an exchange rate.

1 view (last 30 days)
I am trying to simulate data representing intensity vs. frequency for a system that exhibits (slow) exchange between a free and ligand bound state during serial addition of the ligand. Using the equations below I plan to extract the rate of exchange and I am also allowing a variable to be adjustable which scales the intensity over the series to a account for issues which decrease intensity other than direct ligand binding. I have gone through the equation line by line, and it seems acceptable, but when i try to run the fitting .m file, I get the following error:
Error using nlinfit (line 142) Error evaluating model function 'lnshp_exchange'.
Error in fit_lnshp_exchange (line 30) [beta,R]=nlinfit(x,y,@lnshp_exchange, beta0);
Caused by: Error using / Matrix dimensions must agree.
I am fairly new to matlab, and previous data and model functions have been simpler. The function .m file and fitting .m file I am trying to use are below:
FUNCTION file:
function f = lnshp_exchange(a,x) %a(1) is k (the rate), a(2) is c (the weighting function allowing each %spectrum to vary in intensity) global K L v1 v2 Tp1 Tp2
t=1/(a(1)*L*(1+K));
p1=K*a(1)*L*t;
p2=1-p1;
w=(v1+v2)*(1/(2-x(i)));
W=v1-v2;
P=t*((1/Tp1*Tp2)-4*pi^2*w^2+pi^2*W^2)+(p1/Tp1)+(p2/Tp2);
Q=t*(2*pi*w-pi*W*(p1-p2));
R=2*pi*w*(1+t*((1/Tp1)+(1/Tp2)))+pi*W*t*((1/Tp1)-(1/Tp2)+pi*W*(p1-p2));
f=a(2)*(P*(1+t*(p2/Tp1 + p1/Tp2))+Q*R)/(P^2+R^2);
end
FITTING file:
%lnshp_exchange.m
% simulation of lineshape to extract kon rate
%used to extract kon from titration lineshape analysis wiht known Kd
%k is kon, p1 is protein population, p2 is PL complex population, K is Kd,
%v1 is P shift, v2 is PL shift, Tp1 is T2 of protein, Tp2 is T2 of PL
%complex % %
K=0.0000033;
L=0;
Tp1=4.96;
Tp2=7.25;
v1=12.212;
v2=13.114;
x = [13.627 13.549 13.471 13.393 13.315 13.236 13.158 13.08 13.002 12.924 12.846 12.768 12.689 12.611 12.533 12.455 12.377 12.299 12.221 12.142 12.064 11.986 11.908 11.83 11.752];
y = [-1065.0592 -1211.71057 -856.98804 -531.41229 -893.48578 -986.63025 -918.69916 -109.00397 831.30347 993.21808 294.64252 -152.99203 -315.96314 146.8889 301.44775 838.57312 8316.95019 67597.40625 134763.2188 87617.96875 16666.29883 3421.37939 1571.36316 410.51562 72.57593
-1703.73584 -168.12866 789.64722 47.88208 1053.0144 2968.02295 4267.29297 2023.13257 2187.24414 1070.43872 494.38843 441.92407 982.57385 2506.96777 5016.04541 8904.80859 21991.72266 58715.40625 81474.96875 51473.53906 16955.95312 7286.82764 5943.39551 1376.10278 1042.12024
-39.62695 700.45947 880.60693 1672.54761 5490.44434 10250.34961 10380.7793 6425.10059 6905.46533 6553.79688 6200.93555 5450.68262 4783.33496 5999.4292 7567.62451 11676.40039 25238.00391 44612.70703 48212.02734 31467.79102 14820.61523 7434.34668 4969.66113 3741.05395 1968.92871
1043.43018 1107.2915 867.73779 5146.99512 10612.75098 15606.82129 17111.01367 15553.41211 13606.79297 11644.58398 9904.29102 8363.57617 8394.67383 9185.61426 11504.78906 15183.7041 18597.78906 19856.51953 18239.32031 14534.8418 10632.95703 7895.86572 5961.84131 2730.13037 844.76611
955.84497 2015.80225 2387.98047 4048.4624 11210.70312 16925.08203 19031.31055 17363.96484 14155.95312 12351.83789 12254.92773 12554.97559 8054.34082 7015.4541 9957.03027 12886.91992 15665.52832 16681.64844 15349.11035 11559.93652 6778.93994 2888.54883 2653.48828 1996.67981 462.49243
816.61426 1340.49951 2559.72241 4974.0498 11448.54688 18123.99414 22077 21455.01172 17330.70312 13263.42481 12302.31055 12430.32227 10510.09863 8609.22852 8700.05859 11117.88281 13825.72266 13037.2832 10703.99121 7670.78467 4957.00293 2900.64209 1040.67224 2628.21582 2260.03833
1724.04956 1974.71899 3508.62842 6614.21143 14141.95898 22662.28711 29631.51758 30185.56836 24522.78125 20425.20117 17182.12695 14347.07422 11488.67969 9485.25684 8113.57764 7390.01367 6137.35059 4852.66846 4065.29761 1038.77881 2389.02588 2390.88355 1635.01221 887.71338 418.07263
1017.89062 3290.80713 2461.18628 6337.92041 10516.60254 27073.01367 47504.57031 49338.07031 32321.31836 17756.05273 10994.10547 7089.5957 5681.59668 5528.44141 3266.34937 1683.14502 1117.92139 1018.42493 1810.63977 1372.02917 409.14453 208.14368 503.91351 749.15692 609.94269
478.78796 276.61523 943.86523 3912.71606 10665.20508 26013.48047 49891.15625 52589.57031 32083.81641 14279.88379 7967.62402 2074.96045 1551.20606 2382.36328 1204.91748 660.64294 433.22656 293.98059 877.6582 425.44501 306.06085 582.08484 762.74091 773.78149 848.60443
-212.7782 806.15381 1836.09131 2703.93774 6954.34522 24789.8418 52799.79297 55614.00391 30688.68164 11702.89648 7908.93018 7220.44189 991.13086 176.91162 426.85034 595.06372 1902.92786 1999.74829 261.81982 127.63409 1488.17212 819.18957 809.03778 547.50305 402.78043
421.03442 679.49683 1223.23584 1319.02173 7267.28906 27667.15625 57490.22656 59154.5625 30209.49023 10021.16992 5106.10645 2895.95361 263.38672 4925.26855 535.75537 470.86707 656.37109 723.2934 -176.93835 -80.99463 460.82233 592.15222 624.12665 -272.06909 -973.29181
144.40857 243.18066 855.50024 1911.75195 7785.42334 24537.07617 53844.03125 56273.88672 29028.33984 12262.52441 8271.73731 4480.6875 752.30762 290.34033 593.19531 956.20917 722.90625 289.04041 86.98852 193.8642 372.54791 40.64154 29.01819 -144.94244 -311.20447
712.8313 30.62354 297.38672 1315.11987 5841.479 24975.31641 58066.73438 60861.19141 30210.11523 11398.08008 9358.29785 7345.10352 4206.13623 648.10962 1151.78479 1603.72144 994.3385 783.32489 472.1008 347.92139 159.12595 182.41538 -399.45337 2497.44824 336.76511];
beta0=[1*10.^6 0.8];
[beta,R]=nlinfit(x,y,@lnshp_exchange, beta0);

Answers (0)

Categories

Find more on Linear and Nonlinear Regression 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!