Shock Absorber Design Through Matlab Iteration

In summary: Calculate the area under the graph using the trapz() functionarea = trapz(loads);In summary, to calculate the area under the graph generated by your for loop, you can use the trapezoidal rule by dividing the graph into small trapezoids and calculating the area of each trapezoid. You can then use the trapz() function in MATLAB to calculate the total area under the graph.Another way to approach this problem is to use the polyfit() and polyval() functions
  • #1
violentj
2
0
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 postIs 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;
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
 
Last edited:
Physics news on Phys.org
  • #2
.
Thank you for sharing your code and the problem you are facing. It seems like you are trying to calculate the area under the graph generated by your for loop. There are a few ways to approach this problem, and I will provide two potential solutions for you.

One way to calculate the area under the graph is to use the trapezoidal rule. This involves dividing the graph into small trapezoids and calculating the area of each trapezoid. The sum of these areas will give you an estimate of the total area under the graph. To implement this in your code, you can create a vector to store the values of the load at each stroke, and then use the trapz() function in MATLAB to calculate the area under the graph. Here is an example of how you can modify your code to do this:

%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;

%Create a vector to store the values of load at each stroke
loads = [];

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;

%Add the value of load at
 

1. What is the purpose of using Matlab for shock absorber design?

Matlab is a powerful computational software that allows for efficient and accurate analysis and optimization of complex engineering systems. It is commonly used in shock absorber design to iteratively test and refine various design parameters, saving time and resources compared to traditional trial-and-error methods.

2. How does the iteration process in Matlab work for shock absorber design?

The iteration process in Matlab involves defining a set of design parameters, such as spring stiffness and damping coefficient, and running simulations to evaluate the performance of the shock absorber. Based on the results, the design parameters are adjusted and the simulation is repeated until the desired performance is achieved.

3. What type of data can be obtained from Matlab simulations for shock absorber design?

Matlab simulations can provide a range of data, including displacement, velocity, acceleration, force, and energy for the shock absorber under different operating conditions. This data can be used to assess the performance of the design and make necessary improvements.

4. Can Matlab simulations help with predicting the lifespan of a shock absorber?

Yes, Matlab simulations can be used to predict the lifespan of a shock absorber by analyzing the stress and strain on the components over time. This allows for the identification of potential failure points and the optimization of the design for increased durability.

5. Are there any limitations to using Matlab for shock absorber design?

While Matlab is a powerful tool for shock absorber design, it does have some limitations. It relies heavily on accurate input data and assumptions, so the results may not always be fully representative of real-world conditions. Additionally, it may require a significant amount of computational resources and time to run simulations, depending on the complexity of the design.

Back
Top