close all
clc

%% Plot Plane z=0, Analyse Fz-x and Fz-y 
clear
Fx = 1978.8775;

xv = 1;
yv = 2;
zv = 3;
xf = 4;
yf = 5;
zf = 6;
xpower = 10;
ypower = 11;
zpower = 12;

Y = xlsread('z=0.xlsx');
[m,n] = size(Y(:,xv));
j = 0;
for i = 1:m
    if Y(i,xv) >= 2.2
        j = j + 1;
        Pxfit(j,1) = Y(i,xv);
        Pyfit(j,1) = Y(i,yv);
        Fxfit(j,1) = Fx-Y(i,xf);
        Fyfit(j,1) = Y(i,yf);
        Fzfit(j,1) = - Y(i,zf);
    end
end

[xq,yq] = meshgrid(min(Pxfit):0.25:max(Pxfit),min(Pyfit):0.05:max(Pyfit));
zqx = griddata(Pxfit,Pyfit,Fxfit,xq,yq);
zqy = griddata(Pxfit,Pyfit,Fyfit,xq,yq);
zqz = griddata(Pxfit,Pyfit,Fzfit,xq,yq);

Pxfit2 = [Pxfit;Pxfit];
Pyfit2 = [Pyfit;-Pyfit];
Fxfit2 = [Fxfit;Fxfit];
Fyfit2 = [Fyfit;-Fyfit];
Fzfit2 = [Fzfit;Fzfit];

[xq2,yq2] = meshgrid(min(Pxfit2):0.25:max(Pxfit2),min(Pyfit2):0.05:max(Pyfit2));
zqx2 = griddata(Pxfit2,Pyfit2,Fxfit2,xq2,yq2);
zqy2 = griddata(Pxfit2,Pyfit2,Fyfit2,xq2,yq2);
zqz2 = griddata(Pxfit2,Pyfit2,Fzfit2,xq2,yq2);

figure(1)
a0 = 41;
a1 = 48; b1 = 14;
a2 = 53; b2 = 13;
a3 = 61; b3 = 11;
% a0 = 41;
% a1 = 49; b1 = 13;
% a2 = 55; b2 = 13;
% a3 = 65; b3 = 9;
set(gcf,'color',[1 1 1])
grid on
hold on
plot(xq2(a0,:),zqz2(a0,:),'.','MarkerSize',30,'color',[1,0,0])
plot(xq2(a1,1:b1),zqz2(a1,1:b1),'o','MarkerSize',12,'color',[0,1,0])
plot(xq2(a2,1:b2),zqz2(a2,1:b2),'^','MarkerSize',12,'color',[0,0,1])
plot(xq2(a3,1:b3),zqz2(a3,1:b3),'s','MarkerSize',12,'color',[0,0,0])

xlabel('x_d/m','FontSize',24,'Fontname','Times New Roman')
ylabel('f_b_z/N','FontSize',24,'Fontname','Times New Roman')
h = legend(['y_d=' num2str(yq2(a0,1))],['y_d=' num2str(yq2(a1,1))],['y_d=' num2str(yq2(a2,1))],['y_d=' num2str(yq2(a3,1))]);
set(h,'FontSize',24,'Fontname','Times New Roman');

plot(xq2(a0,:),zqz2(a0,:),'color',[1,0,0])
plot(xq2(a1,1:b1),zqz2(a1,1:b1),'color',[0,1,0])
plot(xq2(a2,1:b2),zqz2(a2,1:b2),'color',[0,0,1])
plot(xq2(a3,1:b3),zqz2(a3,1:b3),'color',[0,0,0])

figure(2)
a0 = 1; b0 = 41-27;
a1 = 3; b1 = 41-5;
a2 = 5; b2 = 41-1;
a3 = 8; b3 = 41-11;
set(gcf,'color',[1 1 1])
grid on
hold on
plot(yq2(41-b0:41+b0,a0),zqz2(41-b0:41+b0,a0),'.','MarkerSize',30,'color',[1,0,0])
plot(yq2(41-b1:41+b1,a1),zqz2(41-b1:41+b1,a1),'o','MarkerSize',12,'color',[0,1,0])
plot(yq2(41-b2:41+b2,a2),zqz2(41-b2:41+b2,a2),'^','MarkerSize',12,'color',[0,0,1])
plot(yq2(41-b3:41+b3,a3),zqz2(41-b3:41+b3,a3),'s','MarkerSize',12,'color',[0,0,0])

xlabel('y_d/m','FontSize',24,'Fontname','Times New Roman')
ylabel('f_b_z/N','FontSize',24,'Fontname','Times New Roman')
h = legend(['x_d=' num2str(xq2(1,a0))],['x_d=' num2str(xq2(1,a1))],['x_d=' num2str(xq2(1,a2))],['x_d=' num2str(xq2(1,a3))]);
set(h,'FontSize',24,'Fontname','Times New Roman');

plot(yq2(41-b0:41+b0,a0),zqz2(41-b0:41+b0,a0),'color',[1,0,0])
plot(yq2(41-b1:41+b1,a1),zqz2(41-b1:41+b1,a1),'color',[0,1,0])
plot(yq2(41-b2:41+b2,a2),zqz2(41-b2:41+b2,a2),'color',[0,0,1])
plot(yq2(41-b3:41+b3,a3),zqz2(41-b3:41+b3,a3),'color',[0,0,0])

%% Plot Plane y=0, Analyse Fz-z
clear

Fx = 1978.8775;

xv = 1;
yv = 2;
zv = 3;
xf = 4;
yf = 5;
zf = 6;
xpower = 10;
ypower = 11;
zpower = 12;

Y = xlsread('y=0.xlsx');
[m,n] = size(Y);
j = 0;
for i = 1:m
    if Y(i,xv) >= 2.2
        j = j + 1;
        Pxfit(j,1) = Y(i,xv);
        Pzfit(j,1) = Y(i,zv);
        Fxfit(j,1) = Fx-Y(i,xf);
        Fyfit(j,1) = Y(i,yf);
        Fzfit(j,1) = - Y(i,zf);
    end
end

[xq,yq] = meshgrid(min(Pxfit):0.25:max(Pxfit),min(Pzfit):0.05:max(Pzfit));
zqx = griddata(Pxfit,Pzfit,Fxfit,xq,yq);
zqy = griddata(Pxfit,Pzfit,Fyfit,xq,yq);
zqz = griddata(Pxfit,Pzfit,Fzfit,xq,yq);

figure(3)
a0 = 1; b0 = 2;
a1 = 3; b1 = 2;
a2 = 5; b2 = 1;
a3 = 7; b3 = 1;
set(gcf,'color',[1 1 1])
grid on
hold on
plot(-yq(b0:11,a0),zqz(b0:11,a0),'.','MarkerSize',30,'color',[1,0,0])
plot(-yq(b1:11,a1),zqz(b1:11,a1),'o','MarkerSize',12,'color',[0,1,0])
plot(-yq(b2:11,a2),zqz(b2:11,a2),'^','MarkerSize',12,'color',[0,0,1])
plot(-yq(b3:11,a3),zqz(b3:11,a3),'s','MarkerSize',12,'color',[0,0,0])

xlabel('z_d/m','FontSize',24,'Fontname','Times New Roman')
ylabel('f_b_z/N','FontSize',24,'Fontname','Times New Roman')
h = legend(['x_d=' num2str(xq(1,a0))],['x_d=' num2str(xq(1,a1))],['x_d=' num2str(xq(1,a2))],['x_d=' num2str(xq(1,a3))]);
set(h,'FontSize',24,'Fontname','Times New Roman');

plot(-yq(b0:11,a0),zqz(b0:11,a0),'color',[1,0,0])
plot(-yq(b1:11,a1),zqz(b1:11,a1),'color',[0,1,0])
plot(-yq(b2:11,a2),zqz(b2:11,a2),'color',[0,0,1])
plot(-yq(b3:11,a3),zqz(b3:11,a3),'color',[0,0,0])