MATLAB Answers


This question is closed.


How to solve system of 2nd order differential equations using ode23 or ode45.

Asked by Jesse Crotts on 9 Dec 2018 at 0:20
Latest activity Closed by madhan ravi
on 9 Dec 2018 at 8:03
I'm trying to use ode23 or ode45 to solve a system of 2nd order differential equations that look like this:
where M and K are 10x10 matrices and Q is a 10x1 matrix.
I would appreciate any help with it.
Here is the same problem I have been working on with 2x2 matrices but cant get it to work either:
clc; clear
time = (0:.001:22.5)';
M = [1 2; 3 4];
K = [5 6; 7 8];
x0 = [0;0;0;0]; %[position,velocity]
[t1,x1,x2,x3,x4]=ode23(@(t1,x) trick(t1,x,M,K), time, x0);
title('Stepped Response(Underdamped)');
This function calls trick:
%2x2 sys
function f = trick(t,x,M,K)
f = zeros(4,1);
f(1) = x(2);
f(2) = x(3);
MinvnegK = -inv(M)*K;
delta = MinvnegK*[x(4) x(5)]';
f(3) = delta(1);
f(4) = delta(2);


Sign in to comment.

0 Answers