MATLAB: How to store solutions of roots-function inside matrix

MATLABroots for loop

I have a simple equation v=ax^4+bx^3+cx^2+dx^1+ex^0 for which I would like to calculate the roots.But not only for a single value of v, but for a range of v's (let's say 10 v-values) The solutions of the roots function must be stored in a matrix of size (5,10). a=1.1; b=-1.7; c=-1.3; d=0.1 e=-0.4;
v=[1E2 2E2 2E3 2E4 2E5 2E6 2E7 2E8 2E9 3E0] for i=1:length(v) findsolutionsxvalues=[roots([a b c d e -v(i)]);]% end
Unfortunately I can only access the results for the last volume 3E0. The rest of the answers (45 elements) are displayed in the command window but are not stored in the matrix.
Example code is attached.Thanks for your help, Antoine

Best Answer

The easiest way is simply to save it as a cell array:

findsolutionsxvalues{i} = [roots([a b c d e -x(i)]);]% set each x(i) equal to the volume function 

Note the curly braces ‘{}’ denoting a cell array.

I cannot run the code you posted, since there is no ‘x’ vector.