Question

help me with this. Im done with task 1 and on the way to do task 2. but I don't know how to do it. I attach 2 file function of rksys and ode45 ( the first is rksys and second is ode 45) . thank for your help

Consider the spring-mass damper that can be used to model many dynamic systems -- ----- ------- m Applying Newtons Second Lam function (RR = rk4sys (dydt, tspan, yo, h) 3 rk4sys: fourth-order Runge-Kutta for a system of ODES l - 1k4sys (dydt, tspan,vmid = yli,:) + k1.*hh./2; k2 = dydt (tethh/2ymid); vmid = xli,:) + k2*hh/2; 13 = dydt (te+hh/2, ymid); vend = yli, :) + k3

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

%i have created the script as well as the function. You need to change parameters as needed. If any error is there, please tell in comments, I will fix it

y0=[0;0];
tstart=0;
tend=1;%edit it accordingly
h=.1;%change as needed
tspan=[tstart,tend];
[t_23s,y_23s]=ode23s(@forcedvibration,tspan,y0);%calling ode23s
[t_45,y_45]=ode45(@forcedvibration,tspan,y0);%calling ode45
[tp,yp]=rk4sys(@forcedvibration,tspan,y0,h);%calling rk4sys
plot(t_23s,y_23s(:,1),t_45,y_45(:,1),tp,yp(:,1))
xlabel('t')
ylabel('x')
title('displacement')
legend('ode 23s','ode45','rk4sys')
figure
plot(t_23s,y_23s(:,2),t_45,y_45(:,2),tp,yp(:,2))
xlabel('t')
legend('ode 23s','ode45','rk4sys')
ylabel('x''')
title('slope')

%the required function
function y = forcedvibration(t,x)
A=1000;
B=100;
k=50;
w=pi/2;
m=10;
f=A*exp(-B*t).*cos(w.*t);
y=[x(2);(f-k*x(1)-B*x(2))/m];
end

Add a comment
Know the answer?
Add Answer to:
help me with this. Im done with task 1 and on the way to do task...
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
  • There are 5 errors in the MATLAB function code below. This function is supposed to numerically...

    There are 5 errors in the MATLAB function code below. This function is supposed to numerically approximate a system of ODEs using Euler's method with a for loop. (a) What are the errors? (b) How would you fix them? 88 388 function (t, y) euler_system (ODEFUN, TSPAN, YO, H) %EULER_SYSTEM (ODEFUN, TSPAN, YO, H) will numerically solve a system fof first order ODEs using Euler's Method, where ODEFUN is a %column vector of the derivative functions, TSPAN is a vector...

  • fix this code for me in math lab and get it to produce a graph and...

    fix this code for me in math lab and get it to produce a graph and send me the new code and picture of the graph. I defined all the equations and constants already, I just can't get it to work and I need help. code : clear;clc; t0=0;tf=100; y0=[1;2]; % input spec ((y(1)- F_1; y(2)-H_1; y(3)- H_3; soln=ode45(@f,[t0,tf],y0); %Solve the set of ODEs t=linspace(t0,tf,100); %create x axis spacing y1=deval(soln,t,1); %get value for y1 @ all t y2=deval(soln,t,2); %get value...

  • I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT...

    I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT WE HAVE A SUB AND HE DIDN'T TEACH IT! ITS EULER AND IMPROVED EULER IN MATLAB! HERE IS THE LINK FOR THE IMAGE FILE THAT SHOWS THE FULL INSTRUCTIONS FOR THE CODE. https://imgur.com/a/gjmypLs Also, here is my code so far that I borrowed form an old assignment but the data is all wrong and the application of the code is slightly different so either...

  • MATLAB help please!!!!! 1. Use the forward Euler method Vi+,-Vi + (ti+1-tinti , yi) for i=0.1, 2, , taking yo-y(to) to be the initial condition, to approximate the solution at 2 of the IVP y'=y-t...

    MATLAB help please!!!!! 1. Use the forward Euler method Vi+,-Vi + (ti+1-tinti , yi) for i=0.1, 2, , taking yo-y(to) to be the initial condition, to approximate the solution at 2 of the IVP y'=y-t2 + 1, 0 2, y(0) = 0.5. t Use N 2k, k2,...,20 equispaced timesteps so to 0 and t-1 2) Make a convergence plot computing the error by comparing with the exact solution, y: t (t+1)2 exp(t)/2, and plotting the error as a function of...

  • In this exercise, your will be creating the function euler2 which applies Euler's method to numerically...

    In this exercise, your will be creating the function euler2 which applies Euler's method to numerically solve a first order ODE, but with no overshoot. Input variables: ODEFUN – A function representing the the equation for y'. It must be a function of t and y. TSPAN – a vector containing the start time and end time (TSPAN = [tStart,tEnd]). Y0 – The value for y at tStart. h – The step size. Output variables: TOUT – The output time...

  • matlab INSTRUCTIONS Consider the spring-mass damper that can be used to model many dynamic systems Applying Newton...

    matlab INSTRUCTIONS Consider the spring-mass damper that can be used to model many dynamic systems Applying Newton's Second Law to a free-body diagram of the mass m yields the following ODE m습+8 +kx=F(t) (1) dt2 Where F() is a forcing function, Consider the case where the forcing function itself is a damped oscillation: Where F F(t)-Ae-Bt COS(wt) (2) For this activity we'll see how we can formulate this ODE for a solution using MATLAB that could be used to study...

  • Solve the following differential equation using MATLAB's ODE45 function. Assume that the all init...

    Solve the following differential equation using MATLAB's ODE45 function. Assume that the all initial conditions are zero and that the input to the system, /(t), is a unit step The output of interest is x dt dt dt To make use of the ODE45 function for this problem, the equation should be expressed in state variable form as shown below Solve the original differential equation for the highest derivative dt 2 dt Assign the following state variables dt dt Express...

  • Problem 1. (15 points) Solve the following system of ODEs using your Euler implementation and ode...

    Problem 1. (15 points) Solve the following system of ODEs using your Euler implementation and ode45 and compare the errors at the final step. Use h 0.1 and 10 steps. What is the exact solution? Problem 2. (15 points) Express the following differential equation as a system of first order ODEs. Identify all critical points and identify their stability. Problem 1. (15 points) Solve the following system of ODEs using your Euler implementation and ode45 and compare the errors at...

  • Solve Example 6.2 on page 111 of textbook, using (1) the 4th order Runge Kutta method...

    Solve Example 6.2 on page 111 of textbook, using (1) the 4th order Runge Kutta method and (2) Simulink method, respectively. Please submit your MATLAB code m file and slx file You can use the results from the code attached below (from the textbook by ODE45 solver) as a reference Example 6.2 ode45 ex.m % This program solves a system of 3 differential equations % by using ode45 function % y1 (0)=0, y2 (0)=1.0, y3 (0)=1.0 clear; clc initial [0.0...

  • Would someone help me with the last 3 questions here, I got the previous ones but need help with the last 3 in red. Than...

    Would someone help me with the last 3 questions here, I got the previous ones but need help with the last 3 in red. Thank you Transcribed: Now that you nd a rst order system of ODEs, you can solve it using the Huens method ac- cording to the material you covered in computational module 2. A template of the code which will help you to get started is also available. Attach the complete code as a pdf page to...

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