tags:

views:

41

answers:

2

In Mathematica, it's easy to expand terms like

(ax^2+bx+c)^n

But is there anyway I can do this in Matlab?

+4  A: 

For any arbitrary expression: not without the Symbolic Toolbox. http://www.mathworks.com/help/toolbox/symbolic/expand.html

However, if you wish to expand polynomials, you can use the conv function. Just run it in a loop.

a = 1;
b = 2;
c = 3;
n = 5;
soln = [a b c];
for i=1:n-1
   soln = conv(soln,[a b c]);
end 
Gilead
Short and sweet! That's something I want, thanks.
Ngu Soon Hui
+3  A: 

You can also use my sympoly toolbox.

>> sympoly a b c x
>> (a*x^2+b*x+c)^3
ans =
    c^3 + 3*b*c^2*x + 3*b^2*c*x^2 + b^3*x^3 + 3*a*c^2*x^2 + 6*a*b*c*x^3 + 3*a*b^2*x^4 + 3*a^2*c*x^4 + 3*a^2*b*x^5 + a^3*x^6
woodchips
@woodchips, thanks! One thing I am not sure, though, is whether your toolbox is compilable to .Net.
Ngu Soon Hui

related questions