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

This homework is due in a few days. I have part of the code, but I can\'t seen t

ID: 2995388 • Letter: T

Question

This homework is due in a few days. I have part of the code, but I can't seen to get it to all work together. Please help!

Energy Stored in a spring: The force required to compress a linear spring is given by the equation; F = kx where, F is the force in Newton's (N), k is the spring constant in Newton's per meter (N/m) and x is the displacement vector - the distance and direction the spring is deformed from its equilibrium length. The potential energy stored in the compressed spring is given by the equation;

Explanation / Answer

clc
display('Energy store in springs');

%answer1 = input('Do you like to run this program (1 = yes, 0 = no)? ');
answer1 = 1;
if answer1 == 1
answer2 = 1;
while answer2 == 1
k = input('Input spring constant array k = ');
F = input('Input the force array F = ');
% k=[100 100 200,10,500,20,30,45];
% F=[200 100,45,500,150,400,10,350];
x = F./k;
E = 0.5*k.*x.^2;
fprintf (' Spring# Spring const.(N/m) Compression(m) Force(N) Energy(J) ');
for i = 1:length(k)
fprintf('%7d %8.2f %17.2f %17.2f %10.2f ',i, k(i),x(i),F(i),E(i));
end
[Emax,j] = max(E);
kmax = k(j);
Fmax = F(j);
fprintf(' Spring %2d with k = %6.2f (N/m) and an applied force of %6.2f (N) ',j,kmax,Fmax);
fprintf(' has the maximum energy stored, E = %7.2f (J) ',Emax);
subplot(2,1,1)
xj = (0:100);
Fj = kmax*xj;
Ej =0.5*kmax.*xj.^2;
plot(xj,Fj)
title('Forces(F) vs. Compression(x)')
xlabel('Compression (m)')
ylabel('Force(N)')
subplot(2,1,2)
plot(xj,Ej)
title('Energy(E) vs. Compression(x)')
xlabel('Compression (m)')
ylabel('Energy(J)')
answer2 = input('Run the program again(1 = yes, 0 = no)? ');
if answer2 == 0
display('Goodbye')
end
end
else
display('Goodbye');
break
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote