1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| clear all;
load('Cil3_50x_onepeak');
s1=length(Zm111(1,:));
s2=length(Zm111(:,1));
k=0;
w=1.4; nu1=0.41; nu2=0.41; E1=103e+9; E2=107e+9;
Estar=((1-nu1^2)/E1+(1-nu2^2)/E2)^-1;
Z1 = 0.3e-9;
Zms = Zm111*0;
Xms = Xm111;
Yms = Ym111;
dimframe=1;
for j=dimframe:s1-2*dimframe
i=dimframe;
while i<s2-2*dimframe
matrice = Zm111(i:i+2*dimframe,j:j+2*dimframe);
massimo = max(max(matrice));
if massimo == Zm111(i+dimframe,j+dimframe)
k=k+1;
peaks(k,3)= Zm111(i+1,j+1);
peaks(k,2)= Ym111(i+1,j+1);
peaks(k,1)= Xm111(i+1,j+1);
f = fittype('a*((x-x0)*cos(th)+(y-y0)*sin(th)).^2+b*(-(x-x0)*sin(th)+(y-y0)*cos(th)).^2+z0','problem',{'x0','y0'},'independent', {'x', 'y'},'dependent', 'z','coefficients', {'a','b','th','z0'});
[cfun,gof] = fit([reshape(Xm111(i:i+2*dimframe,j:j+2*dimframe),[],1),...
reshape(Ym111(i:i+2*dimframe,j:j+2*dimframe),[],1)],...
reshape(Zm111(i:i+2*dimframe,j:j+2*dimframe),[],1),f,...
'problem',{Xm111(i+dimframe,j+dimframe),Ym111(i+dimframe,j+dimframe)},...
'Start', [1,1,0,0],...
'Lower',[-Inf -Inf -pi/2 -Inf],...
'Upper',[0 0 0 Inf]);
peaks(k,3)= Zm111(i+dimframe,j+dimframe);
peaks(k,2)= Ym111(i+dimframe,j+dimframe);
peaks(k,1)= Xm111(i+dimframe,j+dimframe);
peaks(k,4)=cfun.a;
peaks(k,5)=cfun.b;
peaks(k,6)=cfun.th;
peaks(k,7)=cfun.z0;
Rmax = -real(1/((cfun.a+cfun.b)-sqrt((cfun.a)^2-(2*cfun.a*cfun.b)+(cfun.b)^2)));
Rmin = -real(1/((cfun.a+cfun.b)+sqrt((cfun.a)^2-(2*cfun.a*cfun.b)+(cfun.b)^2)));
peaks(k,8)= Rmax;
peaks(k,9)= Rmin;
muTmax =((16*Rmax*1e-6*w^2)/(9*Estar^2*Z1^3))^1/3;
muTmin =((16*Rmin*1e-6*w^2)/(9*Estar^2*Z1^3))^1/3;
peaks(k,10)= muTmax;
peaks(k,11)= muTmin;
rmse = gof.rmse;
peaks(k,12)=rmse;
i= i+dimframe;
Ymatr = Ym111(i:i+2*dimframe, j:j+2*dimframe);
Xmatr = Xm111(i:i+2*dimframe, j:j+2*dimframe);
x = reshape(Xmatr, 1,[]);
y = reshape(Ymatr, 1,[]);
z = reshape(Zmatr, 1,[]);
figure
grid on
hold on
Zsphere=cfun(Xm111,Ym111);
surf(Xm111,Ym111,Zsphere);
surf(Xm111,Ym111,Zm111);
plot3(x,y,z,'.','Markersize',15)
zlim([-0.4 0.4])
xlim([min(x)-2.5 max(x)+2.5])
ylim([min(y)-2.5 max(y)+2.5])
caxis([-0.6 0.6])
shading interp
end
i=i+1;
end
j;
end |
Partager