Effacer les filtres
Effacer les filtres

Plot bending moment diagram based on provided formula

3 vues (au cours des 30 derniers jours)
Fatemeh Salar
Fatemeh Salar le 14 Juin 2022
Commenté : Fatemeh Salar le 14 Juin 2022
Hi, I have 2 questions regarding this. I already have equations (I upload it as a picture below please check it out) but apparently I am making mistakes on applying them cause the result are quite different than my expectation.( I guess i am making mistakes based on L and L_span) Could you please tell me what part of my code is wrong ? I am about to upload the equation . And my second question is aside from making mistakes in formula I can not plot it with non-integer steps . Means id i put x=1:0.5:14 then M(1.5) make an error so I gotta stick with only 14 valid integer in my preferred domain.thanks!
<<
x=input('Enter your preferred span : ') q=25; p=400;
if (x>=0 && x<=4)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-69.14;
mright=-238.27;
M=mu+(mleft*(4-x)/4)+(mright*x/4)
elseif (x>4 && x<7)
L=6;
mu=p*x/4;
mleft=-238;
mright=-218;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
elseif (x>=7 && x<10)
L=6;
mu=p*(L-x)/4;
mleft=-238.27;
mright=-218.52;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
elseif (x>=10 && x<=14)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-218.52;
mright=0;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
else
disp('Warning! your span is over than the length of the beam')
end
%%Plot Bending Diagram
q=25;
p=400;
for x=1:14
if (x>=0 && x<=4)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-69.14;
mright=-238.27;
M(x)=mu+(mleft*(4-x)/4)+(mright*x/4);
elseif (x>4 && x<7)
L=6;
mu=p*x/4;
mleft=-238;
mright=-218;
M(x)=mu+(mleft*(L-x)/L)+(mright*x/L);
elseif (x>=7 && x<10)
L=6;
mu=p*(L-x)/4;
mleft=-238.27;
mright=-218.52;
M(x)=mu+(mleft*(L-x)/L)+(mright*x/L);
elseif (x>=10 && x<=14)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-218.52;
mright=0;
M(x)=mu+(mleft*(L-x)/L)+(mright*x/L);
end
end
x=1:14; plot(x,M,'rs-','MarkerSize',3,'MarkerFaceColor','m') grid on xlabel('x (m)') ylabel('M (kN.m)') title('Bending moment diagram')

Réponse acceptée

KSSV
KSSV le 14 Juin 2022
Modifié(e) : KSSV le 14 Juin 2022
This :
put x=1:0.5:14 then M(1.5)
Should be replaced with:
x=1:0.5:14 ;
for i = 1:length(x)
M(i) = % some caclulation using x(i)
end
Note, MATLAB indices should be always positive integers or logicals.
You can modify your code as below:
x=input('Enter your preferred span : ')
q=25; p=400;
if (x>=0 && x<=4)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-69.14;
mright=-238.27;
M=mu+(mleft*(4-x)/4)+(mright*x/4)
elseif (x>4 && x<7)
L=6;
mu=p*x/4;
mleft=-238;
mright=-218;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
elseif (x>=7 && x<10)
L=6;
mu=p*(L-x)/4;
mleft=-238.27;
mright=-218.52;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
elseif (x>=10 && x<=14)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-218.52;
mright=0;
M=mu+(mleft*(L-x)/L)+(mright*x/L)
else
disp('Warning! your span is over than the length of the beam')
end
%%Plot Bending Diagram
q=25;
p=400;
X = 1:0.1:14 ;
for i=1:length(X)
x = X(i) ;
if (x>=0 && x<=4)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-69.14;
mright=-238.27;
M(i)=mu+(mleft*(4-x)/4)+(mright*x/4);
elseif (x>4 && x<7)
L=6;
mu=p*x/4;
mleft=-238;
mright=-218;
M(i)=mu+(mleft*(L-x)/L)+(mright*x/L);
elseif (x>=7 && x<10)
L=6;
mu=p*(L-x)/4;
mleft=-238.27;
mright=-218.52;
M(i)=mu+(mleft*(L-x)/L)+(mright*x/L);
elseif (x>=10 && x<=14)
L=4;
mu=(q*L*x/2)-(q*x*x/2);
mleft=-218.52;
mright=0;
M(i)=mu+(mleft*(L-x)/L)+(mright*x/L);
end
end
plot(X,M,'rs-','MarkerSize',3,'MarkerFaceColor','m')
grid on
xlabel('x (m)')
ylabel('M (kN.m)')
title('Bending moment diagram')

Plus de réponses (0)

Catégories

En savoir plus sur Graphics dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by