×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Program to Solve Spring Problem Assignment Solution

June 14, 2024
Prof. Liam Payne
Prof. Liam
🇺🇸 United States
Programming
Prof. Liam Payne, a seasoned expert in programming, holds a Ph.D. from Harvard University, United States, and boasts 18 years of comprehensive experience. His proficiency lies in delivering top-tier solutions for intricate programming assignments.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
When working on OCaml assignments, make use of pattern matching to simplify your code. It provides a clean and efficient way to handle different cases, especially for recursive functions and data structures like lists and trees. This can reduce complexity and improve readability.
News
Universities worldwide are seeing a surge in programming enrollment, as coding becomes an essential skill across disciplines. To meet growing academic pressures, more students are seeking online help for programming assignments and coursework.

Instructions

Objective

Write a program to solve spring problem in matlab.

Requirements and Specifications

program-to-solve-spring-problem-in-matlab (1)program-to-solve-spring-problem-in-matlab 1 (1)program-to-solve-spring-problem-in-matlab 2 (1)

Source Code

INTERPO function df = interpo(t, y, datagm, T) % Define the critical damping ratio zeta = 0.02; % Compute natural frequency wn = 2*pi/T; % Define the mass in pounds m = 1000; % Compute k k = wn^2 *m; % Get variables x = y(1); v = y(2); xg = datagm(t); df = zeros(2,1); df(1) = v; df(2) = -xg - 2*zeta*wn*v - wn^2 *x; % xpp end QUESTIONS clc, clear all, close all load ELCentro.mat % Define gravity value % g = 9.81; % m/s^2 g = 386.08; % in/s^2 % Scale acceleration fgm = fgm*g; figure plot(tgm, fgm), grid on xlabel('Time (s)') ylabel('Ground Acceleration $\frac{m}{s^{2}}$', 'interpreter', 'latex', 'fontsize', 18) %% Question 2 % Interpolate datagm = griddedInterpolant(tgm, fgm); %% Question 3: See file interpo.m %% Question 4 T = 1; x0 = [0, 1]; [t,y] = ode45(@(t,y)interpo(t,y,datagm,T), tgm, x0); x = y(:,1); v = y(:,2); % Compute acceleration a = diff(v); figure subplot(1,3,1) plot(t(1:end-1), a), grid on xlabel('Time (s)') ylabel('Acceleration $(\frac{in}{s^{2}})$', 'interpreter', 'latex', 'fontsize', 18) title('Acceleration vs. Time') subplot(1,3,2) plot(t, v), grid on xlabel('Time (s)') ylabel('Velocity $(\frac{in}{s})$', 'interpreter', 'latex', 'fontsize', 18) title('Velocity vs. Time') subplot(1,3,3) plot(t, x), grid on xlabel('Time (s)') ylabel('Displacement $(in)$', 'interpreter', 'latex', 'fontsize', 18) title('Displacement vs. Time') %% Question 5 % Now, use different values of T Ts = 0.1:0.1:3; % Vectors to store peak values of acceleration, displacement and velocity accPeaks = zeros(length(Ts),1); velPeaks = zeros(length(Ts),1); dispPeaks = zeros(length(Ts),1); for i = 1:length(Ts) T = Ts(i); [t,y] = ode45(@(t,y)interpo(t,y,datagm,T), t, x0); x = y(:,1); v = y(:,2); % We compute acceleration by using the command diff a = diff(v); % Get peaks accPeaks(i) = max(abs(a)); velPeaks(i) = max(abs(v)); dispPeaks(i) = max(abs(x)); end figure subplot(1,3,1) stem(Ts, accPeaks), grid on xlabel('Period {T (s)}') ylabel('Acceleration $(\frac{in}{s^{2}})$', 'interpreter', 'latex', 'fontsize', 18) title('Spectral Acceleration') subplot(1,3,2) stem(Ts, velPeaks), grid on xlabel('Period {T (s)}') ylabel('Velocity $(\frac{in}{s})$', 'interpreter', 'latex', 'fontsize', 18) title('Spectral Velocity') subplot(1,3,3) stem(Ts, dispPeaks), grid on xlabel('Period {T (s)}') ylabel('Displacement $(in)$', 'interpreter', 'latex', 'fontsize', 18) title('Spectral Displacement') %% Report % In this work an analysis of the dynamics of a structure under the effects of an earthquake (ground acceleration) % is carried out. Through integration methods and graphical analysis, the results of acceleration, velocity % and displacement of the structure are analyzed. % In Figure 1 we can observe the values of the ground acceleration for a time window of 54 seconds. % We can see that the ground acceleration reaches a maximum peak of 134.6 inches. % In Figure 2, we can see the dynamic results of the structure. We see that the structure suffers % a small displacement (maximum 6 inches) thanks to the damping effect that the structure has, which minimizes % the damage caused by earthquakes. % In Figure 3 we see the spectral analysis of the structure. This analysis is extremely important since it allows us to detect % if the structure is prone to greater damage for low or high frequency earthquakes. In this case, we see that % the structure is prone to damage for low frequencies (high periods), since we see that for longer periods % the displacement of the structure increases, which means that the oscillation amplitude is greater and % therefore it can break (taking as an example a structure similar to a skyscraper

Similar Samples

Discover our quality through a variety of programming homework samples. These examples demonstrate our proficiency in handling diverse coding challenges across multiple languages. Check out these samples to see how we can help you achieve excellence in your programming assignments.