Hey guys,
I would like to solve these equations using ode45 in
MATLAB
QUESTION 1)
QUESTION 2)
where k and c are:
For a better understanding of how these values came about:
I deeply appreciate your assistance to these guys.
Thanks
Question 1)
MATLAB code is given below in bold letters.
clc;
close all;
clear all;
% define the time range
t = 0:0.1:5;
% define the initial conditions
x0 = [1 ; 1];
[t,y] = ode45(@vdp1,t,x0);
% Plot the solutions fot y(t) and ydot(t) against
t.
figure;plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of Equation with ODE45');grid;
xlabel('Time t');
ylabel('Solution x1(t) and x2(t)');
legend('x1','x2')
function dydt = vdp1(t,x)
% inpuut
u = ones(size(t));
% Assume the constants
a1 = 1;
b1 = 1;
c1 = 1;
v1 = 1;
b2 = 1;
c2 = 1;
v2 = 1;
% Define the derivatives of the states ydot(t)
dydt = [a1*x(1)-b1*x(1)*x(2)-c1*x(1)-v1*u;
b2*x(1)*x(2)-c2*x(2)-v2*u];
The result is plotted below
Question 2)
MATLAB code is given below in bold letters.
clc;
close all;
clear all;
% define the time range
t = 0:0.1:10;
% define the initial conditions
x0 = [1 ; 1];
[t,y] = ode45(@vdp1,t,x0);
% Plot the solutions fot y(t) and ydot(t) against
t.
figure;plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of Equation with ODE45');grid;
xlabel('Time t');
ylabel('Solution x1(t) and x2(t)');
legend('x1','x2');
function dydt = vdp1(t,x)
% inpuut
k = ones(size(t));
% Assume the constants
d = 1;
c = 1;
k = 1;
m = 1;
% Define the derivatives of the states ydot(t)
dydt = [x(2);1/m*(-d*x(2)-c*x(1)+k)];
The result is plotted below
Hey guys, I would like to solve these equations using ode45 in MATLAB QUESTION 1) QUESTION 2) where k and c are: For a better understanding of how these values came about: I deeply appreciate you...