Biomedical Engineering Reference
In-Depth Information
>>
p
¼
[1 14 71 154 120];
>>
r
¼
roots(p)
r
¼
5.0000
4.0000
3.0000
2.0000
The difference between the two commands is that “solve” allows us to symbolically solve
for the roots without specifying the coefficients of the polynomial such as the well-known
quadratic equation:
>>
syms a b c y x
solve('a * x 2
>>
þ
b * x
þ
c
¼
0')
ans
¼
[1/2/a * (
(b 2
4 * a * c) (1/2))]
b
þ
4 * a * c) (1/2))]
In solving for the response in many dynamic systems we need to solve a system of equa-
tions for several unknown variables such as the coefficients in the natural response.
Suppose we needed to solve
(b 2
[1/2/a * (
b
299, which we did using a
matrix approach. We can also solve a system of equations using the “solve” command by
typing
K 1 þ K 2 ¼
3 and
5
K 1
3
K 2 ¼
>>
syms k1 k2
>>
[k1, k2]
¼
solve('k1
þ
k2
¼
3', '
5 * k1
3 * k2
¼
299')
k1
¼
154
k2
¼ 157
There are many other syntaxes available using the “solve” command; use the MATLAB
help command to learn about them or consult other references.
The MATLAB command for solving ordinary differential equations is “dsolve”. The syn-
tax involves using the capital letter “D” to denote a derivative, “D2” to denote the second
derivative, “D3” to denote the third derivative, and so on. The syntax for the argument of
this command involves writing the given differential equation and the initial conditions,
each separated by a comma and enclosed in a single quote. For example, to solve the fol-
lowing differential equation for
t
0
y þ
y þ
4
3
y ¼
0
with initial conditions
y
(0)
¼
1 and
y
(0
Þ¼
0 using MATLAB's “dsolve”, we have
>>
dsolve('D2y
þ
4 * Dy
þ
3 * y
¼
0', 'Dy(0)
¼
0', 'y(0)
¼
1')
ans
¼
1/2 * exp(
3 * t)
þ
3/2 * exp(
t)
Search WWH ::




Custom Search