time | calls | line |
---|
| | 63 | function sse = fiterror(params,time,data,func_type, show_fitting,ploidy1x)
|
| 1957 | 64 | G1_a = abs(params(1)); % G1_height.
|
| 1957 | 65 | G1_b = params(2); % G1_location.
|
| 1957 | 66 | G1_c = abs(params(3)); % G1_width.
|
| 1957 | 67 | if (G1_c == 0)
|
| | 68 | G1_c = 0.001;
|
| | 69 | end;
|
| | 70 | % a = height.
|
| | 71 | % b = location.
|
| | 72 | % c = width.
|
| | 73 |
|
0.01 | 1957 | 74 | G1_fit = G1_a*exp(-0.5*((time-G1_b)./G1_c).^2);
|
| 1957 | 75 | fitted = G1_fit;
|
| | 76 |
|
| 1957 | 77 | if (show_fitting == 1)
|
| | 78 | %------------------------------------------------------------------
|
| | 79 | % show fitting in process.
|
| | 80 | figure(1);
|
| | 81 | % show data being fit.
|
| | 82 | plot(data,'x-','color',[0.75 0.75 1]);
|
| | 83 | hold on;
|
| | 84 | % show fit curve.
|
| | 85 | plot(fitted,'-','color',[0 0.5 0.5],'lineWidth',2);
|
| | 86 | % show ploidy lines.
|
| | 87 | line([ploidy1x*1 ploidy1x*1 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 88 | line([ploidy1x*2 ploidy1x*2 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 89 | line([ploidy1x*3 ploidy1x*3 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 90 | line([ploidy1x*4 ploidy1x*4 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 91 | line([ploidy1x*5 ploidy1x*5 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 92 | line([ploidy1x*6 ploidy1x*6 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 93 | line([ploidy1x*7 ploidy1x*7 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 94 | line([ploidy1x*8 ploidy1x*8 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 95 | line([ploidy1x*9 ploidy1x*9 ],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 96 | line([ploidy1x*10 ploidy1x*10],[0 max(data)],'color',[0 0 0],'lineWidth',2);
|
| | 97 | hold off;
|
| | 98 | %------------------------------------------------------------------
|
| | 99 | end;
|
| | 100 |
|
0.01 | 1957 | 101 | width = 0.5;
|
| 1957 | 102 | switch(func_type)
|
| 1957 | 103 | case 'cubic'
|
| 1957 | 104 | Error_Vector = (fitted).^2 - (data).^2;
|
0.02 | 1957 | 105 | sse = sum(abs(Error_Vector));
|
| | 106 | case 'linear'
|
| | 107 | Error_Vector = (fitted) - (data);
|
| | 108 | sse = sum(Error_Vector.^2);
|
| | 109 | case 'log'
|
| | 110 | Error_Vector = log(fitted) - log(data);
|
| | 111 | sse = sum(abs(Error_Vector));
|
| | 112 | case 'fcs'
|
| | 113 | Error_Vector = (fitted) - (data);
|
| | 114 | %Error_Vector(1:round(G1_b*(1-width))) = 0;
|
| | 115 | %Error_Vector(round(G1_b*(1+width)):end) = 0;
|
| | 116 | sse = sum(Error_Vector.^2);
|
| | 117 | otherwise
|
| | 118 | error('Error: choice for fitting not implemented yet!');
|
| | 119 | sse = 1;
|
| | 120 | end;
|
| 1957 | 121 | end
|
Other subfunctions in this file are not included in this listing.