Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing the code for #3 and 4. I was able to write the code for #1 a

ID: 3882455 • Letter: I

Question

I need help writing the code for #3 and 4. I was able to write the code for #1 and 2 but I am stuck on 3 and 4 and I am also running out of time. Please help I will attach my codes for 1 and 2 in case you need it.

For #1 the code is below

clear all

clc

L= input('what is the length of the bar');

N= input('what is the number of intervals ');

q0= input('what is this value');

E= 2.1e11;

A= 0.02;

h = L/N;

k= 1000000;

A_1= zeros(N);

for c=2:N-1

A_1(c,c)=-2;

A_1(c,c-1)=1;

A_1(c,c+1)=1;

  

end

A_1(N,N-1)=2;

A_1(1,1)=-2;

  

A_1 (1,2)= 1;

A_1(N,N)=-2-2*h*k/(A*E);

   A_1;

x= h:h:L;

for i= 1:N

if x(i)<= L/2

   q(i)= q0*((2*x(i))^2)/L^2;

else

   q(i)=q0*(2-2*x(i)/L);

end

end

A_1

q

b= zeros(N,1);

for i= 1:N

   b(i)= - ((h^2)*q(i)/(E*A));

end

b

U= A_1^-1*b

For #2 the code is below

clc

clear all

E= 2.1e11;

A= 0.02;

L= 5;

q0= 5000;

G = [2 4 8 16 4096]

for j= 1:5

N= G(j);

k= 1000000;

   A_1= zeros(N);

   h = L/N;

for c=2:N-1

A_1(c,c)=-2;

A_1(c,c-1)=1;

A_1(c,c+1)=1;

  

end

A_1(N,N-1)=2;

A_1(1,1)=-2;

  

A_1 (1,2)= 1;

A_1(N,N)=-2-2*h*k/(A*E);

   A_1

x= h:h:L;

for i= 1:N

if x(i)<= L/2

   q(i)= q0*(2*x(i))^2/L^2;

else

   q(i)=q0*(2-2*x(i)/L);

end

end

A_1

q

b= zeros(N,1);

for i= 1:N

   b(i)= - ((h^2)*q(i)/(E*A));

end

b

U= A_1

plot (x,U)

hold on

end

  

A bar with uniform cross-sectional area A, elastic modulus E, and length L is loaded with distributed loads qfx). The bar is fixed on the left end and attach to the spring of stiffness K, which is relaxed when the bar is undeformed. A as .02m2, the Young's modulus E as 210 GPa (Steel ASTM A36), K = 1 000kN/m 1. Spring constant K q(x) f( spring) Cross sectional Area : A(m2) L (m) Ed2u(x) =-q(x);0

Explanation / Answer

For Case #3 the code is
clear all
clc
L= input('what is the length of the bar');
N= input('what is the number of intervals ');
q0= input('what is this value');
E= 2.1e11;
A= 0.02;
h = L/N;
k= 1000000;
A_1= zeros(N);

for c=2:N-1
A_1(c,c)=-2;
A_1(c,c-1)=1;
A_1(c,c+1)=1;
  
end

A_1(N,N-1)=2;
A_1(1,1)=-2;
  
A_1 (1,2)= 1;
A_1(N,N)=-2-2*h*k/(A*E);

A_1;
x= h:h:L;

for i= 1:N
if x(i)<= L/2
q(i)= q0*((2*x(i))^2)/L^2;
else
q(i)=q0*(2-2*x(i)/L);
end
end
A_1
q

b= zeros(N,1);

for i= 1:N
b(i)= - ((h^2)*q(i)/(E*A));
end
b

U= A_1^-1*b
For Case #2 the code is
clc
clear all

E= 2.1e11;
A= 0.02;
L= 5;
q0= 5000;
G = [2 4 8 16 4096]

for j= 1:5
N= G(j);
k= 1000000;
A_1= zeros(N);
h = L/N;


for c=2:N-1
A_1(c,c)=-2;
A_1(c,c-1)=1;
A_1(c,c+1)=1;
  
end

A_1(N,N-1)=2;
A_1(1,1)=-2;
  
A_1 (1,2)= 1;
A_1(N,N)=-2-2*h*k/(A*E);

A_1
x= h:h:L;

for i= 1:N
if x(i)<= L/2
q(i)= q0*(2*x(i))^2/L^2;
else
q(i)=q0*(2-2*x(i)/L);
end
end
A_1
q

b= zeros(N,1);

for i= 1:N
b(i)= - ((h^2)*q(i)/(E*A));
end
b

U= A_1
plot (x,U)
hold on
end