load('summary.mat');

figure; hold on;
errorbar(liftHeight1v,SiMean1v/1e-3,SiStd1v/1e-3,'k','DisplayName','1V','LineWidth',2);
errorbar(liftHeight2v,SiMean2v/1e-3,SiStd2v/1e-3,'k','DisplayName','2V','LineWidth',2);
errorbar(liftHeight3v,SiMean3v/1e-3,SiStd3v/1e-3,'k','DisplayName','3V','LineWidth',2);
errorbar(liftHeight4v,SiMean4v/1e-3,SiStd4v/1e-3,'k','DisplayName','4V','LineWidth',2);
axis([100 600 0 45]);
x=linspace(0,600,1000);
p1=0.0022903; p2=-0.50344; p3=21.758;
plot(x,p1*x.^2+p2*x+p3,'k--');
xlabel('Lift Height [nm]','FontSize',12,'FontWeight','Bold');
ylabel('Force [~mv]','FontSize',12,'FontWeight','Bold');
set(gca,'FontSize',12,'FontWeight','Bold');



figure; hold on;
errorbar(liftHeight1v,SiO2Mean1v/1e-3,SiO2Std1v/1e-3,'k','DisplayName','1V','LineWidth',2);
errorbar(liftHeight2v,SiO2Mean2v/1e-3,SiO2Std2v/1e-3,'k','DisplayName','2V','LineWidth',2);
errorbar(liftHeight3v,SiO2Mean3v/1e-3,SiO2Std3v/1e-3,'k','DisplayName','3V','LineWidth',2);
errorbar(liftHeight4v,SiO2Mean4v/1e-3,SiO2Std4v/1e-3,'k','DisplayName','4V','LineWidth',2);
axis([100 600 0 45]);
x=linspace(0,600,1000);
p1=0.0025239; p2=-0.39789; p3=5.7789;
plot(x,p1*x.^2+p2*x+p3,'k--');
xlabel('Lift Height [nm]','FontSize',12,'FontWeight','Bold');
ylabel('Force [~mv]','FontSize',12,'FontWeight','Bold');
set(gca,'FontSize',12,'FontWeight','Bold');

figure; hold on;
errorbar(liftHeight1v,ratioMean1v,ratioStd1v,'k','DisplayName','1V','LineWidth',2);
errorbar(liftHeight2v,ratioMean2v,ratioStd2v,'k','DisplayName','2V','LineWidth',2);
errorbar(liftHeight3v,ratioMean3v,ratioStd3v,'k','DisplayName','3V','LineWidth',2);
errorbar(liftHeight4v,ratioMean4v,ratioStd4v,'k','DisplayName','4V','LineWidth',2);
plot([100 600],[1 1],'k--');
axis([100 600 0 3]);
xlabel('Lift Height [nm]','FontSize',12,'FontWeight','Bold');
ylabel('Ratio Response','FontSize',12,'FontWeight','Bold');
set(gca,'FontSize',12,'FontWeight','Bold');

annotation(gcf,'arrow',[0.361525704809287 0.449419568822554],[0.469997679814385 0.470997679814385],'LineWidth',2);
annotation(gcf,'arrow',[0.285240464344942 0.200663349917081],[0.161412993039443 0.160092807424594],'LineWidth',2);
annotation(gcf,'textbox',[0.0956268656716428 0.20505800464037 0.206296849087894 0.0626450116009259],'String',{'Near','Response'},'HorizontalAlignment','center','FontWeight','bold','FontSize',12,'FitBoxToText','off','LineStyle','none');
annotation(gcf,'textbox',[0.427202321724712 0.431554524361948 0.206296849087894 0.118329466357303],'String',{'Far','Response'},'HorizontalAlignment','center','FontWeight','bold','FontSize',12,'FitBoxToText','off','LineStyle','none');
annotation(gcf,'line',[0.276948590381426 0.373134328358209],[0.127610208816705 0.526682134570766],'LineWidth',2);



figure; hold on;
errorbar(liftHeight1v(2:end),ratioMean1v(2:end),ratioStd1v(2:end),'k','DisplayName','1V','LineWidth',2);
errorbar(liftHeight2v(4:end),ratioMean2v(4:end),ratioStd2v(4:end),'k','DisplayName','2V','LineWidth',2);
errorbar(liftHeight3v(4:end),ratioMean3v(4:end),ratioStd3v(4:end),'k','DisplayName','3V','LineWidth',2);
errorbar(liftHeight4v(6:end),ratioMean4v(6:end),ratioStd4v(6:end),'k','DisplayName','4V','LineWidth',2);
plot([100 600],[1 1],'k--');
x=linspace(150,550,1000);
p1=-1.9398e-06; p2=0.0023866; p3=0.21956;
plot(x,p1*x.^2+p2*x+p3,'k--');
axis([100 600 0.4 1.1]);
xlabel('Lift HResponse','FontSize',12,'FontWeight','Bold');
set(gca,'FontSize',12,'FontWeight','Bold');





liftHeightUnique=unique([liftHeight1v,liftHeight2v,liftHeight3v,liftHeight4v]);
arr=zeros(4,length(liftHeightUnique));
for i=1:length(liftHeightUnique)
	idx1v=find(liftHeight1v==liftHeightUnique(i));
	idx2v=find(liftHeight2v==liftHeightUnique(i));
	idx3v=find(liftHeight3v==liftHeightUnique(i));
	idx4v=find(liftHeight4v==liftHeightUnique(i));
	
	if isempty(idx1v), arr(1,i)=0; else arr(1,i)=SiMean1v(idx1v); end
	if isempty(idx2v), arr(2,i)=0; else arr(2,i)=SiMean2v(idx2v); end
	if isempty(idx3v), arr(3,i)=0; else arr(3,i)=SiMean3v(idx3v); end
	if isempty(idx4v), arr(4,i)=0; else arr(4,i)=SiMean4v(idx4v); end

end

v2=(1:4).^2;
figure; hold on;
for i=1:15
	plot(v2,arr(:,i))
end
set(gca,'FontSize',12,'FontWeight','Bold');




