From: Snow White on
I tried the following:

for Nc_index=1:Nc
theroots(:,Nc_index)= roots(p(Nc_index)); %%computing roots of the equation inorder to find the refractive index
end
But when i chk the size :
size(theroots) is 0 105600
although i have already defined theroots

bye

"Snow White" <gulesaman(a)gmail.com> wrote in message <hscpg0$5qc$1(a)fred.mathworks.com>...
> Hello,
>
> are you saying i shud compute all the values in a loop? A B etc isnt that going to take a long time.
>
> Bye
>
> "Steven Lord" <slord(a)mathworks.com> wrote in message <hsbolq$7vj$1(a)fred.mathworks.com>...
> >
> > "Snow White" <gulesaman(a)gmail.com> wrote in message
> > news:hsblpk$p0$1(a)fred.mathworks.com...
> > > D=(sin(temp_theeta_incident)^2);
> > > size(temp_rho) is 1 105600
> > >
> > > theoretically i should get 4 roots for each matrix element (image pixel).
> > > is there a solution for this?:s
> >
> > Create a 4-by-105600 matrix theroots, then loop from k = 1 to 105600.
> > Create p from the kth elements of A, B, C, and D and compute the roots of
> > that polynomial, then store them in the corresponding column of theroots.
> >
> > Alternately you _could_ use some of the methods described in section 3 of
> > this Wikipedia page:
> >
> > http://en.wikipedia.org/wiki/Quartic_function
> >
> > and simply plug in your vectors to one or more of those expressions.
> >
> > --
> > Steve Lord
> > slord(a)mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
From: Steven Lord on

"Snow White" <gulesaman(a)gmail.com> wrote in message
news:hscpg0$5qc$1(a)fred.mathworks.com...
> Hello,
>
> are you saying i shud compute all the values in a loop? A B etc isnt that
> going to take a long time.

No, you can compute A, B, C, and D as you did before (and if you made them
column vectors instead of row vectors you could even compute your
polynomials all at once) -- but call ROOTS inside the loop.

And as for taking a long time -- you're trying to find the roots of a
hundred thousand polynomials. That's going to take a little bit of time no
matter what you do.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Snow White on
Hello,

I tried doing the following:

theroots=zeros(4,Nc);
p= [A.^2 (2.*A.*C-1) ((2.*A.*B)+(C.^2)+D) 2.*B.*C B.^2];
for Nc_index=1:Nc
theroots(Nc_index)= roots(p(Nc_index)); %%computing roots of the equation inorder to find the refractive index
end
i get the following error:
??? Subscripted assignment dimension mismatch.

bye

"Steven Lord" <slord(a)mathworks.com> wrote in message <hsecis$fjr$1(a)fred.mathworks.com>...
>
> "Snow White" <gulesaman(a)gmail.com> wrote in message
> news:hscpg0$5qc$1(a)fred.mathworks.com...
> > Hello,
> >
> > are you saying i shud compute all the values in a loop? A B etc isnt that
> > going to take a long time.
>
> No, you can compute A, B, C, and D as you did before (and if you made them
> column vectors instead of row vectors you could even compute your
> polynomials all at once) -- but call ROOTS inside the loop.
>
> And as for taking a long time -- you're trying to find the roots of a
> hundred thousand polynomials. That's going to take a little bit of time no
> matter what you do.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
From: Steven Lord on

"Snow White" <gulesaman(a)gmail.com> wrote in message
news:huqnd4$6h1$1(a)fred.mathworks.com...
> Hello,
>
> I tried doing the following:
>
> theroots=zeros(4,Nc);
> p= [A.^2 (2.*A.*C-1) ((2.*A.*B)+(C.^2)+D) 2.*B.*C B.^2];
> for Nc_index=1:Nc
> theroots(Nc_index)= roots(p(Nc_index)); %%computing roots of
> the equation inorder to find the refractive index
> end
> i get the following error:
> ??? Subscripted assignment dimension mismatch.

You want to extract _rows_ of p, not individual elements, and store the
results of computing the roots of those polynomials in _rows_ of theroots,
not individual elements. For example, p(2, :) extracts the 2nd row, all
columns, from p. Use that to modify the code appropriately.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Snow White on
P is a row vector of size 1 7749245

"Steven Lord" <slord(a)mathworks.com> wrote in message <hur27e$fti$1(a)fred.mathworks.com>...
>
> "Snow White" <gulesaman(a)gmail.com> wrote in message
> news:huqnd4$6h1$1(a)fred.mathworks.com...
> > Hello,
> >
> > I tried doing the following:
> >
> > theroots=zeros(4,Nc);
> > p= [A.^2 (2.*A.*C-1) ((2.*A.*B)+(C.^2)+D) 2.*B.*C B.^2];
> > for Nc_index=1:Nc
> > theroots(Nc_index)= roots(p(Nc_index)); %%computing roots of
> > the equation inorder to find the refractive index
> > end
> > i get the following error:
> > ??? Subscripted assignment dimension mismatch.
>
> You want to extract _rows_ of p, not individual elements, and store the
> results of computing the roots of those polynomials in _rows_ of theroots,
> not individual elements. For example, p(2, :) extracts the 2nd row, all
> columns, from p. Use that to modify the code appropriately.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>