plese help someone.I need to solve simultaneous differential eqns with multiple dependent variable.

1 view (last 30 days)
here is what I written to solve these eqns. I'm getting error.I don't have any initial conditions.Also I need to plot y1,y2 and y3.I'm still learning matlab and don't have idea how to solve this problem.
clc;clear;close;
%write given values
m1=1; m2=2; m3=3;
c1=3; c2=1;
k1=2; k2=2;
f1=5; f3=2;
%call the function named 'func'
[y1 y2 y3]=func(m1,m2,m3,c1,c2,k1,k2,f1,f3)
function [y1 y2 y3] =
func(m1,m2,m3,c1,c2,k1,k2,f1,f3)
%define variables
syms y1(t) y2(t) y3(t)
%write differential equations
eqn1=m1*diff(y1,t,2)==f1-c1*(diff(y1,t)-diff(y2,t))-k1*(y1-y2);
eqn2=m2*diff(y2,t,2)==-c1*(diff(y2,t)-diff(y1,t))-k1*(y2-y1)-c2*(diff(y2,t)-diff(y3,t))-k2*(y2-y3);
eqn3=m3*diff(y3,t,2)==-f3-c2*(diff(y3,t)-diff(y2,t))-k2*(y3-y2);
%solve these eqns
y = dsolve(eqn1,eqn2,eqn3);
y1=y.y1;
y2=y.y2;
y3=y.y3;
end
  6 Comments
Walter Roberson
Walter Roberson on 6 Sep 2021
Maple says that there is a closed-form solution. It involves particular computed values (call it S) with terms with exp(S*t)/S and terms with exp(S*t) without division by S, and some other terms. Here, what I referred to as S for explanation purposes, is the set of four roots of a polynomial of degree 4. The roots of a quartic have closed form, so it is possible to write a closed form for the solution... just long.
The full set of roots of a quartic always involve some expressions with sqrt(-1) . In cases where all of the roots are real, then ideally the imaginary terms cancel out... but in practice because of rounding, it is common that when you work symbolically, that you end up with some left-over imaginary components, so you have to be careful.
Paul
Paul on 6 Sep 2021
I was able to get Matlab to return an expression in terms of roots(), and I assumed that if a closed form for those roots existed Matlab would have provided it.

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!