Consider some data in the following form
Sample = [1 2 3 4 5 6 7 8 9 10]';
Data = [10 10 10 10 8 5 2 1 0.6 0.4]';
Now I know for a fact this data should form a straight line when plotted with a semilog axis:
The problem is sample no. 1, 2, 3 and 4 all max out at 10 due to a limitation of an instrument used. So what I would like to do is fit a straight line to samples 5:10, and then use that to extrapolate back so I can estimate the values of 1, 2, 3 and 4.
I am confused as to how to do this in MATLAB, my attempt is as follows:
Sample = [1 2 3 4 5 6 7 8 9 10]';
Data = [10 10 10 10 8 5 2 1 0.6 0.4]';
Sample(1:4) = [];
Data(1:4) = [];
x = Sample;
y = Data;
p = polyfit(x,y,0);
x1 = Sample;
f1 = polyval(p,x1);
figure;
semilogy(Sample,Data,'ro');
hold on
plot(x1,f1,'b--')
which produces this plot...