[Scilab-users] Evaluating a polynomial on a square matrix
Dang Ngoc Chan, Christophe
Christophe.Dang at sidel.com
Tue Sep 24 10:31:06 CEST 2019
Hi,
I've got some time this morning (-: so this one seems to work and should be a bit more efficient:
// **********
P = %s^2 + 2*%s + 3
C = coeff(P)
n = size(C, "c")
if n > 1 then
stringP = "X1 = x; "
for i = 3:n
stringP = stringP+"X"+string(i-1)+" = X"+string(i-2)+"*x; "
end
else
stringP = ""
end
stringP = stringP+"Y = "+string(C(1))
for i = 2:n
stringP = stringP+" + "+string(C(i))+"*X"+string(i-1)
end
deff("[Y] = fctP(x)", stringP)
// **********
Regards
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
More information about the users
mailing list