Its polynomial function

Its polynomial function

Its polynomial function

Matlab dimensional vector represented by a polynomial

Example: create a generic one-dimensional vector into an expression string format

= S function pprintf (P)
 % pprintf This function can be converted into one-dimensional vector format string mathematical expressions% p: input parameters, one-dimensional vector format is%    S: output parameter string format 
 IF the nargin> . 1          % input parameter judged too much 
    error ( " too much arguements iNPUT " ); 
End 
the while (P ( . 1 ) == 0 )% elements of the input vector are all 0 
    P ( . 1 ) = []; 
End 
L = length (P );% calculated vector length 
S = '' ;
 for V = . 1 : L
     iF P (V) == 0        % when the constant term is 0
    Continue ; 
    ELSEIF L == . 1       % when the length of the vector. 1 
        S = strcat (num2str (P (v))); 
    ELSEIF v == L% when v is a vector of the last value 
        S = strcat (S, ' + ' , num2str (P (v))); 
    ELSEIF v == . 1       % when the first value v is a vector 
        S = strcat (num2str (P (v)), ' X ^ { ' , num2str (Lv), ' } ' ); 
    P ELSEIF (V) == . 1    when the vector element value. 1 
        S = strcat (S, ' + ' ,'x^{',num2str(L-v),'}');
    else
        s=strcat(s,'+',num2str(p(v)),'x^{',num2str(L-v),'}');
    end
end
end

Execute the following script (create a graphical window to the function expression string set as the title):

p=[5 4 6 1 0 8 7 6];

figure;

title (pprintf (p));

 

operation result:

 

 

 

 

Solving the roots of a polynomial of equation solving

p=[3 -2 -4];

r=roots(p)

Solutions have to:

r =

 

    1.5352

   -0.8685

 

Examples

r = roots  is returned as column vectors of   a polynomial representation of the root. Input   is comprising a   vector of polynomial coefficients to X n-  begin coefficient.  Coefficients represent intermediate power equation does not exist. For example:  the representative polynomial. 3 X 2 + 2 X -2.(p)ppn+10p = [3 2 -2]

 

 

Guess you like

Origin www.cnblogs.com/asahiLikka/p/11577742.html