Question

Exercise: MATLAB / Simulink: Use the MATLAB function ode45 to solve ordinary differential equation mi+bi+kr 0 for the following cases. (for more information about ode45 https://www.mathworks.com/help/matlab/ref/ode45.html) a) m-1, b-1, k-25 b) m 1, b 10, k- 25 c) m1, b-11, k-25 Keep the simulation time 5 seconds and zero initial velocity and the initial displacement 1 for all cases. Plot displacement of the mass x for all three cases in one figure and compare them: which of them decays fastest? Why is that?Please do not REPOST the same answer as in all of the other ones because they dont work! I keep getting this error When I try to use it plot (t ,x(:, 5)) hold on (t, x) ode45 (func, o 51, 1 01 ErEoE: Invalid expzession. When calling a unction or indexing a vaziable, use pazentheses. Otherwise, check tor mismatched delimiters

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function dxdt-odesecondorder(t, x,m,b,k) dxdt_1-x (2): dxdt 2-- (b*x(2)+k*x(1))/m; end

Save this function file separately

%initial conditions x(0) 1, x(0)-0 initial x-l; initial_dxdt-o; t span [o 5]; [t,x]=ode45 ( @(ta) odesecondorder ( t,x, 1,1,25) , t-span, [initial-x plot(t,x(:,1)); initial-dxdt]);% m=1,bs1.k-25 xlabel(t)ylabel(x); hold on; [t,x]=ode45 ( @(ta) odesecondorder (t,x, 1,10, 25) , t-span, [initial-x initial-dxdt]);%m=1,bs10, k=25 plotted as dashed line plot(t,x(:,1),--) [t,x]=ode45 ( @(ta) odesecondorder(t,x, 1,11,25) , t-span, [initial-x plot(t,x(:,1)); initial-dxdt]);%m=1,bs11,k-25 plot color yellow hold off;the above program is the actual program to run.

File Edit View Insert Tools Desktop Window Help 0.8 0.6 0.4 0.2 0 0.2 -0.4 -0.6 0.8 4

In the above plot blue line corresponds to part (a), dashed line corresponds to part (b) and the other is part(c). Pasting codes below.

%mx''+bx'+kx=0

%initial conditions x(0)=1, x'(0)=0

initial_x=1;

initial_dxdt=0;

t_span=[0 5];

[t,x]=ode45(@(t,x) odesecondorder(t,x,1,1,25),t_span,[initial_x initial_dxdt]);% m=1,b=1,k=25

plot(t,x(:,1));

xlabel('t');ylabel('x');

hold on;

[t,x]=ode45(@(t,x) odesecondorder(t,x,1,10,25),t_span,[initial_x initial_dxdt]);%m=1,b=10,k=25 plotted as dashed line

plot(t,x(:,1),'--')

[t,x]=ode45(@(t,x) odesecondorder(t,x,1,11,25),t_span,[initial_x initial_dxdt]);%m=1,b=11,k=25 plot color yellow

plot(t,x(:,1));

hold off;

function dxdt=odesecondorder(t,x,m,b,k)

dxdt_1=x(2);

dxdt_2=-(b*x(2)+k*x(1))/m;

dxdt=[dxdt_1;dxdt_2];

end

Add a comment
Know the answer?
Add Answer to:
Please do not REPOST the same answer as in all of the other ones because they...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please show all work and answer all parts of the question. Please do not repost the question and ...

    Please show all work and answer all parts of the question. Please do not repost the question and if you do please at least include the actual code and not the written answer that is incorrect to other posts. Consider the initial boundary value problem (IBVP) for the 1-D wave equation on a finite domain: y(0,t) 0, t > 0 t > 0 y(1,0) f(x) where f(x) =-sin ( 2 π-π (a) Plot the initial condition f(x) on the given...

  • a can be skipped Consider the following second-order ODE representing a spring-mass-damper system for zero initial...

    a can be skipped Consider the following second-order ODE representing a spring-mass-damper system for zero initial conditions (forced response): 2x + 2x + x=u, x(0) = 0, *(0) = 0 where u is the Unit Step Function (of magnitude 1). a. Use MATLAB to obtain an analytical solution x(t) for the differential equation, using the Laplace Transforms approach (do not use DSOLVE). Obtain the analytical expression for x(t). Also obtain a plot of .x(t) (for a simulation of 14 seconds)...

  • Objective: This activity has the purpose of helping students to to use either Simulink or VisSim to simulate the system behavior based on its Block Diagram representation and plot its response...

    Objective: This activity has the purpose of helping students to to use either Simulink or VisSim to simulate the system behavior based on its Block Diagram representation and plot its response Student Instructions: The following spring-mass-damper system has no external forcing, that is Lu(0) 0. At time t"0 it has an initial condition for the spring, which it is distended by one unit; yO) 1. The system will respond to this initial condition (zero-input-response) until it reaches equilibriunm. | yin«...

  • .matlab Objective: This activity has the purpose of helping students to to use either Simulink or VisSim to simulate the system behavior based on its Block Diagram representation and plot its resp...

    .matlab Objective: This activity has the purpose of helping students to to use either Simulink or VisSim to simulate the system behavior based on its Block Diagram representation and plot its response. Student Instructions: The following spring-mass-damper system has no external forcing, that is u(0)-0. At time t- 0 it has an initial condition for the spring, which it is distended by one unit: y(0)-1. The system will respond to this initial condition (zero-input-response) until it reaches equilibrium. 0)1initial condition...

  • modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd...

    modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd edition % Spring Mass Damper system with initial displacement function SolveODEs() clf %clear any existing plots % Time range Initial Conditions [t,y] = ode45( @deriv, [0,2], [1,0] ); % tvals yvals color and style plot( t, y(:,1), 'blue'); title('Spring Mass Damper with initial displacement'); xlabel('Time - s'); ylabel('Position - ft'); pause % hit enter to go to the next plot plot( t, y(:,2), 'blue--');...

  • Can someone help me out with this. I can't get my MATLAB to do these correctly,...

    Can someone help me out with this. I can't get my MATLAB to do these correctly, thanks! Solve the following differential equations using the Matlab function "ode45”, ”ode23” or “ode 15s". For all cases use odeset to set the stats to on, so you can see the process for the solver. Plot your result. Use a legend on your plots. (a) y' =-2y y(0) = 5, tfinal = 2 (b) y" + 3 y' + 25 y = 0 y(0)...

  • please answer all questions and show all steps 3. Draw the magnitude characteristic of the Bode...

    please answer all questions and show all steps 3. Draw the magnitude characteristic of the Bode plot of the following transfer function: Hsout20(0.1s + 1 Vin S(s1)(0.01s +1) a) ldentify the poles and zeros b) Sketch the magnitude plot. The y-axis should be in dB. The x-axis should logarithmic, but labeled in rad/sec. Use MATLAB to draw the complete Bode plot and check your answer. If the input current is uln(t)-2 cos(2t + 30%), what is the output voltage. Use...

  • please use MATLAB, screenshot the code and the plots. Answer all parts. Laboratory description: The speed...

    please use MATLAB, screenshot the code and the plots. Answer all parts. Laboratory description: The speed control of a high-speed train is represented by the system shown in Figure 1. The transfer function of the train dynamics is as follows. G(s) = 2 + 10s + 20 Laboratory assignment: Part A. For the open-loop system described by the following block diagram, assume that the input r(t) is a unit step. (1) Compute the steady-state system output Yss. (2) Find the...

  • ***** PLEASE DO NOT REPOST THE SAME ANSWER TO THIS QUESTION FROM ANOTHER PERSON POST OF...

    ***** PLEASE DO NOT REPOST THE SAME ANSWER TO THIS QUESTION FROM ANOTHER PERSON POST OF THIS SAME QUESTION, THOSE ANSWERS ARE NOT ANSWERING WHAT IS BEING ASKED HERE, PLEASE LABEL ANY KEY IN THE ER DIAGRAM AS WELL AS THE CARDINALITY OF RELATIONSHIPS***** Submission Guidelines Prepare the list of entities and their corresponding attributes in Word, and draw the E-R diagram in Visio. Description of Homework For the problem below, ****- List all necessary entities and their corresponding attributes....

  • The equations of motion for a certain mechanical system with two degrees of freedom, can be...

    The equations of motion for a certain mechanical system with two degrees of freedom, can be written as a pair of coupled, second-order, differential equations: (M + m)x - 1/2 mL theta^2 sin(theta) + 1/2 mL theta cos(theta) + k(x - L_0) = 0 1/3 mL^2 theta + 1/2 mLx cos(theta) + 1/2 mgLsin(theta) = 0 We can rewrite them in matrix form, A*qdd - b, to be solved simultaneously: [M + m 1/2 mL cos theta 1/2 mL cos...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT