# Shock Absorber Design Through Matlab Iteration

by violentj
Tags: helicopter, matlab, shock aborber
 P: 2 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: %Given Values force=50620; stat2ext=4/1; comp2stat=3/1; loadfactor=2.5; staticP=7000000; %Loads load4ext=(1/(stat2ext))*(force*loadfactor) load4stat=(force*loadfactor); load4comp=comp2stat*(force*loadfactor); %Pressures p1=(1/(stat2ext))*staticP; p2=staticP; p3=comp2stat*staticP; %Piston Area areaP=load4stat/p2; radiusP=sqrt(areaP/pi); 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; load=areaP*pn; load1=areaP*pn1; load2=areaP*pn2; hold on plot(stroke,load) plot(stroke,load1) plot(stroke,load2) hold off Thanks any suggestions or pointers would be greatly appreciated