## Shock Absorber Design Through Matlab Iteration

Calculating area under graph from results of a for loop

Im currently designing a shock absorber for an aircraft undercarriage, i have input all the relevant information and formulas into Matlab and created an M file with a functioning for loop giving a graph. The problem i'm having now is that in order to work out the area under the graph that i get from the file i need a line of best fit, which cannot be plotted in matlab on a for loop with the use of hold on and hold off. The code i wrote is at the bottom of this post

Is it possible to either put the results of the for loop into a vector to plot or failing that another way to get matlab to calculate the area under each graph.

The code i have created is below:

Code:
%Given Values

force=50620;
stat2ext=4/1;
comp2stat=3/1;
staticP=7000000;

%Pressures

p1=(1/(stat2ext))*staticP;
p2=staticP;
p3=comp2stat*staticP;

%Piston Area

strokemax=0.5;

n1=1.1;
n2=1.35;

for stroke=0.1:0.01:0.5;

%Displacement

displacement=strokemax*areaP;

v1=(displacement*p3)/(p3-p1);
v3=v1-displacement;

volumedown=stroke*areaP;
vn=v1-volumedown;
pn= (p1*v1)/vn;
pn1= (p1*v1^1.1)/vn;
pn2= (p1*v1^1.35)/vn;

hold on

hold off