using least square fit to get the aT and bT for shifting small amplitude oscillatory shear (SAOS) data to a master curve.
Initially I wish to use lsqnonlinear or lscurvefit, but it didn't work out.
now I use 3-D matrix to map a range of aT and bT then from the minimum of square, to find the best fit aT and bT for G' along, or G" along or G' and G" together.
load saos0C.txt
w=saos0C;
load saos0C2.txt
w=saos0C2;
x=w(:,1);
y1=w(:,2);
y2=w(:,3);
lx=log10(x);
ly1=log10(y1);
ly2=log10(y2);
figure(2); plot(lx,ly1,lx,ly2);
load saos-10C.txt
w_shift=saos_10C;
load saos10C.txt
w_shift=saos10C;
load saos20C.txt
w_shift=saos20C;
x_shift=w_shift(:,1);
y1_shift=w_shift(:,2);
y2_shift=w_shift(:,3);
lx_shift=log10(x_shift);
ly1_shift=log10(y1_shift);
ly2_shift=log10(y2_shift);
N0=size(lx,1);
N0=size(lx_shift,1);
N1=sum(ly1_shift>max(ly1))+3;
lx_shift=lx_shift(N0-N1:N0);
ly2_shift=ly2_shift(N0-N1:N0);
ly1_shift=ly1_shift(N0-N1:N0);
N1=sum(ly1_shift<min(ly1))+2;
lx_shift=lx_shift(1:N0-N1);
ly2_shift=ly2_shift(1:N0-N1);
ly1_shift=ly1_shift(1:N0-N1);
figure(8);
plot(lx_shift,ly2_shift,'x',lx_shift,ly1_shift,'x',lx,ly1,lx,ly2);
lp = polyfit(lx,ly1,N0-N1);
l1y = polyval(lp,lx);
lp2 = polyfit(lx,ly2,N0-N1);
l2y = polyval(lp2,lx);
figure(4);
plot(lx,l1y,'x',lx,l2y,'x',lx,ly1,lx,ly2);
axis([-2,1,1.8,2.8])
tts=log10([1.03;4.46]);
tts=log10([0.96986431;0.28729847]);
tts=log10([0.94786000;0.10592537]);
a_shift=linspace(0.5,0.75,100);
b_shift=linspace(0.009,0.015,200);
b_shift=linspace(-0.016,-0.01,200);
a_shift=linspace(-0.4,-0.7,100);
b_shift=linspace(-0.035,-0.021,200);
a_shift=linspace(-1.1,-0.85,100);
temp1=repmat(lx_shift,1,size(a_shift,2));
temp1(:,:,2)=temp1(:,:);
for i=1:size(b_shift,2)
temp1(:,:,i)=temp1(:,:,1);
end
temp2=repmat(ly1_shift,1,size(a_shift,2));
temp2(:,:,2)=temp2(:,:);
for i=2:size(b_shift,2)
temp2(:,:,i)=temp2(:,:,1);
end
temp3=repmat(ly2_shift,1,size(a_shift,2));
temp3(:,:,2)=temp3(:,:);
for i=2:size(b_shift,2)
temp3(:,:,i)=temp3(:,:,1);
end
tempa=repmat(a_shift,size(lx_shift,1),1);
tempa(:,:,2)=tempa(:,:);
for i=2:size(b_shift,2)
tempa(:,:,i)=tempa(:,:,1);
end
tempb=repmat(b_shift,size(lx_shift,1),1);
tempb(:,:,2)=tempb(:,:);
for i=2:size(a_shift,2)
tempb(:,:,i)=tempb(:,:,1);
end
tempk=zeros(size(lx_shift,1),size(a_shift,2),size(b_shift,2));
tempk(:,1,:)=tempb(:,:,1);
for i=2:size(a_shift,2)
tempk(:,i,:)=tempb(:,:,1);
end
tempb(6,40,50)
tempk(6,50,40)
tempb=tempk;
temp6= polyval(lp2,temp1+tempa) - (temp3+tempb);
temp7= polyval(lp,temp1+tempa) - (temp2+tempb);
temp4=temp6.^2;
temp5=sum(temp4,1);
clearvars temp;
temp(:,:)=temp5(1,:,:);
temp8=temp7.^2;
temp9=sum(temp8,1);
clearvars temp0;
temp0(:,:)=temp9(1,:,:);
figure(1);
pcolor(temp);
tempk=temp0+temp;
[a,b]=min(temp);
[c,d]=min(a);
[e,f]=min(temp0);
[g,h]=min(e);
[k,l]=min(tempk);
[m,n]=min(k);
tts_2=[b_shift(d),a_shift(b(d))];
tts_1=[b_shift(h),a_shift(f(h))];
tts=[b_shift(n),a_shift(l(n))];
figure(3);
plot(lx_shift+tts_2(2),ly2_shift+tts_2(1),'x',lx_shift+tts_2(2),ly1_shift+tts_2(1),'x',lx,ly1,lx,ly2);
figure(4);
plot(lx_shift+tts_1(2),ly2_shift+tts_1(1),'x',lx_shift+tts_1(2),ly1_shift+tts_1(1),'x',lx,ly1,lx,ly2);
figure(5);
plot(lx_shift+tts(2),ly2_shift+tts(1),'x',lx_shift+tts(2),ly1_shift+tts(1),'x',lx,ly1,lx,ly2);
etts=10.^tts;
etts_1=10.^tts_1;
etts_2=10.^tts_2;