message

pdf

School

University of California, Irvine *

*We aren’t endorsed by this school

Course

0809

Subject

Aerospace Engineering

Date

Oct 30, 2023

Type

pdf

Pages

4

Uploaded by DoctorSheepPerson1024

Report
%%%%%%%%% MAE 147 S23 % A.S. Voloshina % Apr 2, 2023 % HW 1 clear variables %% Define constants used in simulation % Mass-spring-damper system constants g = 9.81; % gravity m = 2; % mass (kg) l = 1; % spring rest length c = 0; % damping coefficient k1 = 10; % spring constants for nonlinear spring k2 = 15; % Integration constants endTime = 5; % stop integration after this number of seconds % Initial conditions for your ODE solver y_0 = 0; % initial position of mass relative to y_t yDot_0 = 0; % initial y_Dot %% Integration of differential equations %{ ode45 integrates equations defined in the function systemODEs The inputs to ode45 are as follows: @(t,states) - means integrate the vector states, over time systemODEs(inputs) - means integrate equations found in the function systemODEs, which requires these particular inputs timespan - integrate for this time duration (i.e., end integration when you reach the end of the timespan vector) [y_0 yDot_0] - these are the initial conditions for our integration. We are building the [states] vector, and this is our first input to the integration. In other words, for t=0, we have our initial conditions. Then, for one time tick, ode45 integrates these values and finds the vector [states(1,:)] for t=0+deltaT. Then, [states(1,:)] becomes the initial condition for the next time tick, t = 2*deltaT. ode45 then integrates that and finds [states(2,:)], and so on, until it determines the full [states] vector. Outputs: - t (time of integration, should be the same as the previously defined timespan) - states (the solutions to our ODEs from the integration) %} initialConditions = [y_0 yDot_0]; [t, states] = ode45(@(t,states) systemODEs(t,states, m, g, c, k1, k2),... 0:0.01:endTime, initialConditions); y_t = states(:,1); y_t_Dot = states(:,2);
figure(1); plot(t,y_t); xlabel('time') ylabel('y_t (relative to spring at rest)') %% Plot y_t, y_t_Dot, y_t_DDot on one graph % Part B %Differentiation of y_t_Dot at time = 0.01 initial conditions above y_t_DDot = diff(y_t_Dot)/0.01; figure(2) plot(t,y_t,t,y_t_Dot,t(1:length(y_t_DDot),:),y_t_DDot) xlabel('time') ylabel('y_t (relative to spring at rest)') % You may uncomment the legend below to add a legend to your figures legend('Pos','Vel','Acc') %% Find y_r % Part C % Set c=high and note at what length mass comes to a rest % Or, use roots to solve a 3rd order polynomial c = 15; initialConditions = [y_0 yDot_0]; [t, states] = ode45(@(t,states) systemODEs(t,states, m, g, c, k1, k2),... 0:0.01:endTime, initialConditions); y_t = states(:,1); y_t_Dot = states(:,2); figure(3); plot(t,y_t); xlabel('time') ylabel('y_t (relative to spring at rest)') % From Graph y_r = 0.8932; %% Reset to nominal after Part C initialConditions = [y_0 yDot_0]; [t, states] = ode45(@(t,states) systemODEs(t,states, m, g, c, k1, k2),... 0:0.01:endTime, initialConditions); y_t = states(:,1); y_t_Dot = states(:,2); y_t_DDot = diff(y_t_Dot)/0.01;
%% Plot F_s and F_sl % Part D F_s = k1 .* y_t + k2 .* y_t.^3; %From part c y_r = 0.8932; F_sl = k1 * y_r + k2 * y_r^3 + (k1 + 3 * k2* y_r^2) * (y_t - y_r); y_t_DDot = -F_sl / m - c / m * y_t_Dot + g; figure(4) plot(t,F_s,t,F_sl) xlabel('time') ylabel('Spring Force') legend('Fs','Fsl') figure(5) plot(y_t,F_s,y_t,F_sl) xlabel('y_t') ylabel('Spring Force') legend('Fs','Fsl') %% Part E y_r = 0.8932; F_sl = k1*y_r + k2*y_r^3 + (k1 + 3*k2*y_r^2)*(y_t-y_r); y_t_DDot= -F_sl/m - c/m*y_t_Dot + g; figure(6) plot(t,y_t); hold on plot(t,y_t_Dot); plot(t,y_t_DDot); hold off xlabel('time') ylabel('y_t (relative to spring at rest)') legend('Pos','Vel','Acc') %% Function defining all differential equations function stateDot = systemODEs(~,states, m, g, c, k1, k2) %{ System differential equations. These are the equations of motion that are integrated by ode45. The input to the function is time, states vector, mass and spring parameters. ode45 integrates the vector stateDot, which creates a new states vector for the next time step, and repeats until endTime %}
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
% Extract values from the states vector y_t = states(1); y_t_Dot = states(2); % Nonlinear spring Equations of Motion F_s = k1*y_t + k2*y_t^3; y_t_DDot = -F_s/m - c/m*y_t_Dot + g; % Linear spring Equations of Motion % YOUR CODE HERE % Either remove or comment out the code for the Nonlinear spring EoMs % F_sl = ??? % y_t_DDot = ???; % Collect all states stateDot = [y_t_Dot y_t_DDot]'; end

Browse Popular Homework Q&A

Q: Define seek time and latency time.
Q: Give the interpolation formula for calculating median of grouped series.
Q: Explain Twisted pair (TP).
Q: 1. Let “W” be the set of vectors of the form below. Show that "W" is a subspace of R4. You must show…
Q: ontrast the research methods that are most often used by psychologists and state the advantages and…
Q: Goleta Brewing Company hires only two types of labor, managers and brewing assistants (denoted M and…
Q: Define - MIPS
Q: Sketch the graph of each function, and state its domain, range, and asymptote. Show the x- and…
Q: The table below shows the total variable costs faced by Frankie's Footwear for different quantities…
Q: The cumulative distribution function of a random variable is given by 0, x < 0, 1/2, 0≤x<1, F(x)=…
Q: 3.40 Consider selecting two cards from a well-shuffled deck (unordered and without replace- ment).…
Q: 1. Webster argues that the people have the power to remove anything from the constitution which they…
Q: Do interferons contribute to oncogenesis (if yes, then how exactly)? With pertinent examples,…
Q: 1 (1) { 1 + 2/ 2n :nEN
Q: 4.51. (a) Prove that fe(y² cosx-2e) dx + (2y sin.x - 2xe") dy = 0 around any simple closed curve C.…
Q: How many syntax errors in the following code? Assume all libraries are including
Q: B and Care bases of R³. B = {2 0:0 1|} (a) гот The vector v has coordinate vector [v] B = = (b) Find…
Q: 2,5 Given f(z, y) sin(x + y) where 2s 5t. Find f.(ar(s, t), y(s, t)) f(x(s, t), y(s, t)) =| Note:…
Q: (1) + 1 2n :n EN
Q: a. b. C. What is the distribution of X? What is the covariance of X and S²7 What is the distribution…
Q: what force would be needed to make a 10kg blowling ball accelerate down the alleyway with an…
Q: if the cash flow is grow for indefinite period then isn't the present value calculated as  = Cash…