Filling results from for loop into an array/matrix?
Show older comments
I have this function that computes the coefficients of a polynomial of a certain degree:
n = input('Degree of polynomial: ');
for k = 1:n
syms x y
z(k) = (x+y)^k;
coeff = coeffs(z(k));
c = double(coeff);
end
And I'm trying to store all the coefficients into one matrix. i.e.
c =
1 1
1 2 1
1 3 3 1
...
Instead my value for "c" is just the last iteration of the loop (c = 1 3 3 1). I tried to change c(k) but it doesn't work. What should I do here?
Accepted Answer
More Answers (0)
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!