Mudanças entre as edições de "Uso do calculo simbólico na Matlab"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
(Criou página com '=[http://www.mathworks.com/help/symbolic/use-subs-to-evaluate-expressions-and-functions.html Use subs to Evaluate Expressions and Functions]= Evaluation is one of the most common...')
 
Linha 18: Linha 18:
 
=[http://www.mathworks.com/help/symbolic/formula-rearrangement-and-rewriting.html Formula Rearrangement and Rewriting]=
 
=[http://www.mathworks.com/help/symbolic/formula-rearrangement-and-rewriting.html Formula Rearrangement and Rewriting]=
 
:*[http://www.mathworks.com/help/symbolic/numden.html numden - Extract numerator and denominator]
 
:*[http://www.mathworks.com/help/symbolic/numden.html numden - Extract numerator and denominator]
 +
syms s
 +
H = (s^2 + 5*s + 6)/(s^4 + 7*s + 27)
 +
:H =
 +
::(s^2 + 5*s + 6)/(s^4 + 7*s + 27)
 +
[N,D] = numden(H)
 +
:N =
 +
::s^2 + 5*s + 6
 +
:D =
 +
::s^4 + 7*s + 27
 +
:*[http://www.mathworks.com/help/symbolic/coeffs.html coeffs - Coefficients of polynomial]
 +
Coefficients of Univariate Polynomial - Find the coefficients of this univariate polynomial.
 +
n = coeffs(N)
 +
:n =
 +
::[ 1, 5, 6]
 +
Cuidado, pois os zeros não são inseridos no vetor dos coeficientes.
 +
[d,terms] = coeffs(D)
 +
:d =
 +
::[ 1, 7, 27]
 +
:terms =
 +
::[ s^4, s, 1]

Edição das 14h32min de 3 de junho de 2016

Use subs to Evaluate Expressions and Functions

Evaluation is one of the most common mathematical operations. Therefore, it is important to understand how and when Symbolic Math Toolbox™ performs evaluations. For example, create a symbolic variable, x, and then assign the expression x^2 to another variable, y.

syms x
y = x^2;

Now, assign a numeric value to x.

x = 2;

This second assignment does not change the value of y, which is still x^2. If later you change the value of x to some other number, variable, expression, or matrix, the toolbox remembers that the value of y is defined as x^2. When displaying results, Symbolic Math Toolbox does not automatically evaluate the value of x^2 according to the new value of x.

y
y =
 x^2

To enforce evaluation of y according to the new value of x, use the subs function.

subs(y)
ans =
  4

Formula Rearrangement and Rewriting

syms s
H = (s^2 + 5*s + 6)/(s^4 + 7*s + 27)
H =
(s^2 + 5*s + 6)/(s^4 + 7*s + 27)
[N,D] = numden(H)
N =
s^2 + 5*s + 6
D =
s^4 + 7*s + 27

Coefficients of Univariate Polynomial - Find the coefficients of this univariate polynomial.

n = coeffs(N)
n =
[ 1, 5, 6]

Cuidado, pois os zeros não são inseridos no vetor dos coeficientes.

[d,terms] = coeffs(D)
d =
[ 1, 7, 27]
terms =
[ s^4, s, 1]