

clear all
close all

%load 0806RUNStressStrain.mat
%load 0807RUNStepRes.mat
%alg = load('0806RUNStressStrain.mat');
%alg = load('0806RUNDeploy.mat');
alg = load('0807RUNStepRes.mat');
alg = alg.Data;

var2 = 9;   %pressure sensor
var3 = 10;  %potentiometer

alg2 = alg(:,var2)*250;   % pressure reading in pounds per square inch
alg3 = alg(:,var3)*15;    % strain in inches measured by potentiometer

csarea = 0.25*pi*(2.5^2 - 1.75^2);

alg2 = alg2*csarea;


time = length(alg3);%total sampling time

sf = 100; %sampling frequency in Hertz

st = 1/sf; 

delt= 0.01;

ts = st:delt:time*delt;



figure('Position', [100 100 1000 600])
set(gcf,'color','white');

plot(alg3,alg2);
set(gca,'FontName','times','FontSize',16);

xlabel('Elongation, inches');

%ylabel('Pressure, psi');
ylabel('Force, lbf');

dt = 0.01;
figure('Position', [100 100 1000 600])
set(gcf,'color','white');

sample1_start = 2880.1;
sample2_start = 3239.54;
sample3_start = 3710.32;
sample4_start = 1679.42;
sample_length = 5;

subplot(2,1,1)
plot(ts(sample1_start/dt:(sample1_start+sample_length)/dt)-sample1_start,alg2(sample1_start/dt:(sample1_start+sample_length)/dt));
hold all
plot(ts(sample2_start/dt:(sample2_start+sample_length)/dt)-sample2_start,alg2(sample2_start/dt:(sample2_start+sample_length)/dt));
plot(ts(sample3_start/dt:(sample3_start+sample_length)/dt)-sample3_start,alg2(sample3_start/dt:(sample3_start+sample_length)/dt));
plot(ts(sample3_start/dt:(sample4_start+sample_length)/dt)-sample4_start,alg2(sample4_start/dt:(sample4_start+sample_length)/dt));
set(gca,'FontName','times','FontSize',14);
%legend('Potentiometer');
%ylabel('Pressure, psi');
ylabel('Force, lbf');
subplot(2,1,2)
plot(ts(sample1_start/dt:(sample1_start+sample_length)/dt)-sample1_start,alg3(sample1_start/dt:(sample1_start+sample_length)/dt));
hold all
plot(ts(sample2_start/dt:(sample2_start+sample_length)/dt)-sample2_start,alg3(sample2_start/dt:(sample2_start+sample_length)/dt));
plot(ts(sample3_start/dt:(sample3_start+sample_length)/dt)-sample3_start,alg3(sample3_start/dt:(sample3_start+sample_length)/dt));
plot(ts(sample4_start/dt:(sample3_start+sample_length)/dt)-sample3_start,alg3(sample3_start/dt:(sample3_start+sample_length)/dt));
set(gca,'FontName','times','FontSize',14);
ylabel('Elongation, inches');

xlabel('time(s)');