Azzera filtri
Azzera filtri

How to plot this code?

2 visualizzazioni (ultimi 30 giorni)
hosi
hosi il 10 Lug 2023
Commentato: hosi il 10 Lug 2023
Hey guys I've been trying to learn mathlab and I ended up writing this code the code below:
clc
close all;
clear
L=input("L= ");
Delta_a=input("Delta a= ");
W=input("W= ");
E=input("Modulus Yang= ");
I=input("I= ");
EI=E*I;
N=L/Delta_a;
n=0;
while n<N
a=n*Delta_a;
y1=(-W/(24*EI))*((a^4)-(4*L*(a^3)+(6*(L^2)*(a^2))));
Rd=((3*EI)/(L^3))*(y1);
tb1=(-W*(L^3))/(6*EI);
tb2=(Rd*(a^2))/(2*EI);
yb1=(-W*(L^4))/(8*EI);
yb2=((Rd*(a^3))/(3*EI))+((L-a)*tb2);
thetaB=tb1+tb2;
yB=yb1+yb2;
n=n+1;
if(n>N) end
fprintf('n= #%d\n', n);
fprintf('Reaction D= #%d\n', Rd);
fprintf('Shib= #%d\n', thetaB);
fprintf('Khamesh= #%d\n', yB);
end
So here is my question:
How can I plot yB on diffrent values of a?
My guess is to turn it into a matrix but I have no idea about how to that.

Risposta accettata

N A POORNA CHANDRA
N A POORNA CHANDRA il 10 Lug 2023
hi hosi , here is the code to plot yB on diffrent values of a?
i have assumed few hard coded values instead of taking them as input
clc
close all;
clear
L = 10; % Length (assumed value)
Delta_a = 0.5; % Delta a (assumed value)
W = 100; % W (assumed value)
E = 2e11; % Modulus of elasticity (assumed value)
I = 0.001; % I (assumed value)
EI = E * I;
N = L / Delta_a;
n = 0;
a_values = [];
yB_values = [];
while n < N
a = n * Delta_a;
y1 = (-W / (24 * EI)) * (a^4 - 4 * L * (a^3) + 6 * (L^2) * (a^2));
Rd = (3 * EI / (L^3)) * y1;
tb1 = (-W * (L^3)) / (6 * EI);
tb2 = (Rd * (a^2)) / (2 * EI);
yb1 = (-W * (L^4)) / (8 * EI);
yb2 = ((Rd * (a^3)) / (3 * EI)) + ((L - a) * tb2);
thetaB = tb1 + tb2;
yB = yb1 + yb2;
a_values = [a_values, a];
yB_values = [yB_values, yB];
n = n + 1;
end
plot(a_values, yB_values)
xlabel('a')
ylabel('yB')
title('Plot of yB against a')
grid on
  1 Commento
hosi
hosi il 10 Lug 2023
Your an angel dude! thanks a lot! <3

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by