Re: an error in the help file of matlab?



Here goes the output of matlab prompt
X = pascal(4)
p = poly(X)
polyvalm(p,X)

X =

1 1 1 1
1 2 3 4
1 3 6 10
1 4 10 20

p =

1.0000 -29.0000 72.0000 -29.0000 1.0000

ans =

1.0e-010 *

-0.0013 -0.0063 -0.0104 -0.0242
-0.0048 -0.0218 -0.0360 -0.0798
-0.0115 -0.0512 -0.0822 -0.1812
-0.0229 -0.0973 -0.1560 -0.3410

SONG KE wrote:


i am learning matlab at the moment and i found that, with the
function polyvalm ,if you enter the following comand in the prompt
,
you wouldn't get the same result as that the help file shows.

environement matlab 2006b/WinXP

Here is the sample program given by the help file

"X = pascal(4)
p = poly(X)
polyvalm(p,X)"

Here goes the explaination given by the help file

polyvalmMatrix polynomial evaluation

Syntax
Y = polyvalm(p,X)DescriptionY = polyvalm(p,X) evaluates a
polynomial
in a matrix sense. This is the same as substituting matrix X in
the polynomial p.Polynomial p is a vector whose elements are the
coefficients
of a polynomial in descending powers, and X must be a square
matrix.ExamplesThe Pascal matrices are formed from Pascal's
triangle
of binomial coefficients.
Here is the Pascal matrix of order 4. X = pascal(4)
X =
1 1 1 1
1 2 3 4
1 3 6 10
1 4 10 20 Its characteristic polynomial can be generated
with the poly function. p = poly(X)
p =
1 -29 72 -29 1This represents the polynomial
.Pascal matrices have the curious property that the vector of
coefficients
of the characteristic polynomial is palindromic; it is the same
forward and
backward. Evaluating this polynomial at each element is not very
interesting. polyval(p,X)
ans =
16 16 16 16
16 15 -140 -563
16 -140 -2549 -12089
16 -563 -12089 -43779But evaluating it in a matrix sense
is
interesting. polyvalm(p,X)
ans =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0The result is the zero matrix. This is an
instance of the Cayley-Hamilton
theorem: a matrix satisfies its own characteristic equation.
.



Relevant Pages

  • Re: How to find this summation analytically?
    ... > ans = ... > Matlab refuses to compute symbolically the sum: ... elementary functions with these poles? ... the above function fsatisfies a functional equation ...
    (sci.math)
  • Re: Corelating data in Matlab. Finding the best fit
    ... I want to write a code in Matlab, that will find a best fit. ... the best corelation between the RGB values and Temperature. ...
    (comp.soft-sys.matlab)
  • Matlab speed test
    ... I repeated Dan Spielman's experiment for comparing speed of Matlab under 4 different modes in Matlab 2008a. ... going into the trouble to write mex file does not help to improve speed in such a long for loop of adding 10^8 random numbers. ... Elapsed time is 7.306400 seconds. ...
    (comp.soft-sys.matlab)
  • calling the Maple kernel
    ... Here is something that puzzles me about the interface between Matlab ... Maple functions? ... what I did explicitly in the second command. ...
    (comp.soft-sys.matlab)
  • Re: operation between two matrices
    ... type this command at the MATLAB prompt: ... these commands to exit debug mode and prevent MATLAB from stopping the next ...
    (comp.soft-sys.matlab)

Loading