Filling results from for loop into an array/matrix?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Polynomials finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!