Let's learn something different today.

We study polynomials at school, so we are going to learn anything about how Scilab works with them.

First, this post is moved to fractions of polynomials, for example*:

For work with polynomials in Scilab, we use the %s as the variable. Look the example**:

-->A = %s^2 + %s + 1

A =

2

1 + s + s

-->B = %s + 2

B =

2 + s

-->R = A*B

R =

2 3

2 + 3s + 3s + s

-->Q = A/B

Q =

2

1 + s + s

---------

2 + s

-->S = A + B

S =

2

3 + 2s + s

-->D = A - B

D =

2

- 1 + s

Observe that Scilab works correctly with the coefficients.

Now, let's work more, if we have a fraction of polynomials and we need just the denominator:

-->Q = (%s + 1)/(%s^2 + 2*%s + 2)

Q =

1 + s

---------

2

2 + 2s + s

-->Dem = denom(Q)

Dem =

2

2 + 2s + s

Following with the example, now we need just the numerator:

-->Num = numer(Q)

Num =

1 + s

And now, we need the roots of the denominator and of the numerator:

-->R_Dem = roots(Dem)

R_Dem =

- 1. + i

- 1. - i

-->R_Num = roots(Num)

R_Num =

- 1.

If anyone has studied linear systems, post a comment here.

If nobody has studied it, you can make a post too.

-----------------------

* I use OpenOffice Math for create the equations.

** The blog doesn't work with white spaces, but Scilab puts the higher coefficients after.

## 4 comments:

Is it possible to work with functions of 2 variables?

f(x,y) = x + y

I don't know how to work with two variable simultaneously.

I tried to use the ploy(.) function, like following:

-->v1 = 1:3

v1 =

1. 2. 3.

-->v2 = -2:2:2

v2 =

- 2. 0. 2.

-->y = poly(v2, 'y', 'coeff')

y =

2

- 2 + 2y

-->x = poly(v1, 'x', 'coeff')

x =

2

1 + 2x + 3x

-->x+y

!--error 144

Undefined operation for the given operands

check or define function %p_a_p for overloading

The poly(.) creates a polynomial with any element as variable. You can read more in the Scilab's help.

After a some search and your help I found what I was looking for

here.

Can I ask you to, in a future post, explain how we use "lists" in Scilab?

keep on the good work!!

Hello!

I have a problem with using the poly command, too.

I have an LTI system with a defined TF and I'm using an PIDT1 controller. The controller has a defined regulation, but I do not yet know the parameters KR,TV,TD and T1. I want the closed loop to follow a defined function and I want to solve the problem with a factor comparison.

So I would like to define a polynomial with symbolic parameters for the controller. My problem is that the symbolic toolbox only works with ubuntu. Thats why I'm trying to find another solition with "poly".

I hope you can help me.

Greets,

Nooby

Post a Comment