clear all
close all
%all parameter values
a10=0; a20=5; %initial guess
t_in=0; t_end=10; %initial and final time
h=0.005;
%step size
g=9.8; l=1;q=.5; %all parameter values
%all solution plot
[t_rk,a1_rk,a2_rk]= RK4_sol(t_in,t_end,a10,a20,h,g,l,q);
%Plotting data
figure(1)
plot(t_rk,a1_rk)
title('time vs. Displacement plot')
xlabel('time')
ylabel('displacement')
figure(2)
plot(t_rk,a2_rk)
title('time vs. Velocity plot')
xlabel('time')
ylabel('velocity')
%Function for RK4 solution
function [t_rk,a1_rk,a2_rk]=
RK4_sol(t_in,t_end,a10,a20,h,g,l,q)
%function forRK4 equation solution
f1=@(t,a1,a2,g,l,q) a2;
f2=@(t,a1,a2,g,l,q) (-g/l)*a1-q*a2;
n=(t_end-t_in)/h;
%number of steps
a1_rk(1)=a10;
a2_rk(1)=a20; t_rk(1)=t_in;
%Runge Kutta 4 iterations
for i=1:n
k1=h*f1(t_rk(i),a1_rk(i),a2_rk(i),g,l,q);
l1=h*f2(t_rk(i),a1_rk(i),a2_rk(i),g,l,q);
k2=h*f1(t_rk(i)+h/2,a1_rk(i)+(1/2)*k1,a2_rk(i)+(1/2)*l1,g,l,q);
l2=h*f2(t_rk(i)+h/2,a1_rk(i)+(1/2)*k1,a2_rk(i)+(1/2)*l1,g,l,q);
k3=h*f1(t_rk(i)+h/2,a1_rk(i)+(1/2)*k2,a2_rk(i)+(1/2)*l2,g,l,q);
l3=h*f2(t_rk(i)+h/2,a1_rk(i)+(1/2)*k2,a2_rk(i)+(1/2)*l2,g,l,q);
k4=h*f1(t_rk(i)+h,a1_rk(i)+k3,a2_rk(i)+l3,g,l,q);
l4=h*f2(t_rk(i)+h,a1_rk(i)+k3,a2_rk(i)+l3,g,l,q);
t_rk(i+1)=t_in+i*h;
a1_rk(i+1)=double(a1_rk(i)+(1/6)*(k1+2*k2+2*k3+k4));
a2_rk(i+1)=double(a2_rk(i)+(1/6)*(l1+2*l2+2*l3+l4));
end
end
%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%
using Matlab Assignment 9.3: ODE Ill or pendulum Ill Solve the equation for the small amplitude pendulum without dri...
Solve the following using simulink. 1) The Pit and the Pendulum. Below is the equation for a pendulum. Make a Simulink model of this equation: -k sin(θ) dt2 Compare this model to the simplified model: 2 dt Let k-2. Use as initial conditions, Θ 0.1 and de/dt 0. Print out the model and the results of each equation. What is the difference in the period of the pendulum depending on the model? Repeat with initial conditions of Θ-1.0 and de/dt-0.1
using matlab thank you 3 MARKS QUESTION 3 Background The van der Pol equation is a 2nd-order ODE that describes self-sustaining oscillations in which energy is withdrawn from large oscillations and fed into the small oscillations. This equation typically models electronic circuits containing vacuum tubes. The van der Pol equation is: dt2 dt where y represents the position coordinate, t is time, and u is a damping coefficient The 2nd-order ODE can be solved as a set of 1st-order ODEs,...
MATLAB CODE: Task 2 8y dt Solve the above ordinary differential equation (ODE) using Euler's method with step sizes of: 2. h 0.75 3. h 0.5 4. h 0.001 a) For each step size, plot the results at each step starting from y(0) 3 to y(3). b) Plot on the same figure as part a) the analytical solution which is given by: 9 24 -8t c) Calculate and print the percentage error between the Euler's method and the analytical result...
Using matlab and simulink! Lab Assignment Solve the following problems using the Word and MATLAB. The table should be prepared in Word (Do not use MATLAB) for this. Use the MATLAB PUBLISH to submit your code. If you cannot, you may submit your report as a pdf form (prepare in word and save as pdf). The code, simulink model and figures should be included (print as a pdf or screen capture - consider readability). 1. Create the Simulink model as...
IMPORTANT NOTES: Using the Classical Fouth-order Runge-Kutta method to solve all the following problems, with step size h = 0.01, and t = [0:1] Please use MATLAB to solve the problem. Thanks! 1. Consider the equation of motion governing large deflections of a simple pendulum do + mulsin Mu. ED) where m-mass of the bob - Ikg. I-length, c-damping constant, acceleration due to gravity, MO external torque, e - angular deflection, and t-time. MO) (a) Linearize the equation for small...
solve it using the equation (6-41) on MATLAB. Use Matlab software to plot the following equation 6-44 from the text book Let Vo = 50, R = 10 12, rl = 112, and D is variable, OsDs 1 D (a) Efficiency vs. D 1.0 Ideal 0.8 0.6 Efficiency Nonideal 0.4 0.2 0 0.2 1 0.4 0.6 0.8 1.0 D (6) Figure 6-10 Boost converter for a nonideal inductor. (a) Output voltage; (b) Boost converter efficiency. P V2/R n = (6-43)...
SOLVE USING MATLAB PLEASE THANKS! The governing differential equation for the deflection of a cantilever beam subjected to a point load at its free end (Fig. 1) is given by: 2 dx2 where E is elastic modulus, Izz is beam moment of inertia, y 1s beam deflection, P is the point load, and x is the distance along the beam measured from the free end. The boundary conditions are the deflection y(L) is zero and the slope (dy/dx) at x-L...
write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form....
Set up and solve a boundary value problem using the shooting method using Matlab A heated rod with a uniform heat source may be modeled with Poisson equation. The boundary conditions are T(x = 0) = 40 and T(x = 10) = 200 dTf(x) Use the guess values shown below. zg linspace (-200,100,1000); xin-0:0.01:10 a) Solve using the shooting method with f(x) = 25 . Name your final solution "TA" b) Solve using the shooting method with f(x)-0.12x3-2.4x2 + 12x....
PLEASE SOLVE USING MATLAB The basic differential equation of the elastic curve for a cantilever beam as shown is given as 2 da2 where E = the modulus of elasticity and-the moment of inertia. Show how to use MATLAB ODE solvers to find the deflection of the beam. The following parameter values apply (make sure to do the conversion and use in as the Unit of Length in all calculations): E = 30,000 ksi, I = 800 in4, P-1 kips,...