I am trying to create a function in MATLAB which will expand a bracket to the power of n, where n is a natural number. This is what I have so far:
function expandb = expandb(x,y,n)
z = my_bincoeff1(n);;
syms v x y
v=1:n+1
for i=1:n+1
v(i)=z(i)*x.^(n-i+1)*y.^(i-1);
end
a=0
for i=1+n+1
a=a+v(i)
end
expandb = a;
I get this error when I run it:
??? The following error occurred converting from sym to double:
Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double
array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in ==> expandb at 6
v(i)=z(i)*x.^(n-i+1)*y.^(i-1);
So how do I store 2 variables in an array?