Path: news.mathworks.com!not-for-mail
From: "Mark " <bobbb909@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Polynomial roots
Date: Sat, 1 May 2010 22:10:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 33
Message-ID: <hri8s0$gjm$1@fred.mathworks.com>
References: <hrcsta$g22$1@fred.mathworks.com> <hrcuhl$1r6$1@fred.mathworks.com>
Reply-To: "Mark " <bobbb909@yahoo.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1272751808 17014 172.30.248.38 (1 May 2010 22:10:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 1 May 2010 22:10:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2267776
Xref: news.mathworks.com comp.soft-sys.matlab:631677

"Steven Lord" <slord@mathworks.com> wrote in message <hrcuhl$1r6$1@fred.mathworks.com>...
> 
> "Mark " <bobbb909@yahoo.com> wrote in message 
> news:hrcsta$g22$1@fred.mathworks.com...
> > I'm trying to find the roots of 100 random polynomials of degree 5 and I 
> > need help with finding the roots. I know that I can gernerate 100 
> > polynomials by using
> >                                          >> x=rand([100 6])
> > I know that I can't do >> roots(x)
> > because the the input must be a vector. Is there anyway to to find all the 
> > roots of 100 random polynomials without generating each polynomial one by 
> > one.
> 
> Loop over the rows of x and call ROOTS on each row, storing the roots back 
> into rows or columns of another matrix or into a cell array (depending on 
> how you need them.)
> 
> -- 
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ 
> 
How would I wrtie the for loop? Here is what I got so far

N=100;
x=zeros(100, 6);    % cretes an empty 100 x 6 matrix

for k=1:N
    x(k)=roots(rand([1 6]));
end

x
I know that this won't work so how can I get it to work.