close all
clear all

%August 11, 2009
%Run_0005.mat - Buoy-sphere system
%Run_0006.mat
%Run_0007.mat - Buoy-plate system
%Run_0008.mat

alg = load('Run_0007.mat');
alg = alg.Data;

var2 = 10;   %pressure sensor
var3 = 11;  %potentiometer

alg2 = alg(:,var2)*250;   % pressure reading in pounds per square inch
alg3 = alg(:,var3)*15/39.37;    % strain in inches measured by potentiometer

% alg2 = alg2(89999:299998);
% alg3 = alg3(89999:299998);

alg2 = alg2(89999:139998);
alg3 = alg3(89999:139998);

csarea = 0.25*pi*(2.5^2 - 1.75^2);
alg2 = alg2*csarea*4.4482;

alg2 = alg2 - mean(alg2);
alg3 = alg3 - mean(alg3);

len = length(alg3)-1;
sf = 100; %sampling frequency in Hertz
st = 1/sf; 

t1 = 0:st:len*st;


stim = 500;
t2 = 0:0.1:stim;

tn2= interp1(t1,alg2,t2);

el4= interp1(t1,alg3,t2);



[f2, Pxx32] = tseries2spectrum(t2,tn2);
[f4, Pxx34] = tseries2spectrum(t2,el4);





figure('Position', [100 100 1000 600])
set(gcf,'color','white');

subplot(2,1,1),plot(t2,tn2);
set(gca,'FontName','times','FontSize',16);

xlabel('time (s)');
ylabel('Tension (N)');

subplot(2,1,2),plot(t2,el4);
set(gca,'FontName','times','FontSize',16);

xlabel('time (s)');
ylabel('elongation (m)');


figure('Position', [100 100 1000 600])
set(gcf,'color','white');

subplot(2,1,1),plot(f2,Pxx32);
set(gca,'FontName','times','FontSize',16);

xlabel('Frequency (Hz)');
ylabel('Power Spectrum (Power/Hz)');
L3=legend('Tension (N)');
set(L3,'FontName','times','FontSize', 16,'FontWeight','Bold');

xlim([0 1])

subplot(2,1,2),plot(f4,Pxx34);
set(gca,'FontName','times','FontSize',16);

xlabel('Frequency (Hz)');
ylabel('Power Spectrum (Power/Hz)');
L3=legend('Elongation (m)');
set(L3,'FontName','times','FontSize', 16,'FontWeight','Bold');

xlim([0 1])



