Hi there, I am trying to write a code on composite bars for n cross-sections, could someone help me with a simple code.
Afficher commentaires plus anciens
o = 'Enter the number of cross-sections: ';
n = input(o);
prompt = 'Enter the load in N: ';
F = input(prompt);
if n == 1
y = 'Enter the Youngs modulus of Bar : ';
E1 = input(y);
b = 'Enter the length of Bar: ';
L1 = input(b);
s = 'Enter the diameter of Bar: ';
D1 = input(s);
A = (pi*(D1^2)/4);
Delta = ((F*L1)/(A*E1))
fprintf(' Total extension of the bar: %s.\n' ,Delta );
elseif n==2
y = 'Enter the Youngs modulus of Bar 1: ';
E1 = input(y);
z = 'Enter the Youngs modulus of Bar 2: ';
E2 = input(y);
b = 'Enter the length of Bar 1: ';
L1 = input(b);
d = 'Enter the length of Bar 2: ';
L2 = input(d);
s = 'Enter the diameter of Bar 1: ';
D1 = input(s);
f = 'Enter the diameter of Bar 2: ';
D2 = input(f);
A1 = (pi*(D1^2)/4);
A2 = (pi*(D2^2)/4);
delta1 = ((F*L1)/(A1*E1))
delta2 = ((F*L2)/(A2*E2))
Delta = delta1 + delta2;
fprintf(' Total extension of the bar: %s.\n' ,Delta );
This is the code for 2 cross-sections, the goal is to extend this to n cross-sections. Still learning.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur PID Controller Tuning dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!