How to make the second case working in the following matlab file ?

The first case works well. The case case does not work. Why? I cannot substitute a character with numeric value.

2 Comments

Thank you for help. This is the error I get when I run the program.
------->: 1st case ---
x1 =
(2*cos((5*t)/2))/exp((3*t)/2) + (16*sin((5*t)/2))/(5*exp((3*t)/2))
------->: 2nd case ---
equ =
2*D2x + 6*Dx + 17*x = 0
ic1 =
x(0) = 2
ic2 =
Dx(0) = 5
Warning: Empty equation
> In dsolve at 148
In m_xsubs at 29
x2 =
[ empty sym ]
-------

Answers (1)

syms t x
syms x0 v0
syms m c k
equ = 'm*D2x + c*Dx + k*x = 0';
ic1 = 'x(0) = x0';
ic2 = 'Dx(0) = v0';
x2 = dsolve(equ,ic1,ic2)
x2=subs(x2,{m,c,k,x0,v0},{2,6,17,2,5})

1 Comment

That's right it works in this order.
My goal is to substitute m, c, k & the initial conditions : x0 & v0 before performing the resolution.
It is clear for you. Many thanks for your help. Best wishes.

This question is closed.

Tags

Asked:

on 29 Nov 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!