From: Snow White on
Hello,

I get the following problem in my code can someone help me out with this. Thank you.

A=((sin(temp_theeta_incident).^2).*(1+temp_rho)-2.*temp_rho/(4.*temp_rho).*cos(temp_theeta_incident));
B=((sin(temp_theeta_incident).^2).*(1+temp_rho))/(4.*temp_rho.*cos(temp_theeta_incident));
C=(-2.*(sin(temp_theeta_incident).^2).*(1-temp_rho)+temp_rho)./(4.*temp_rho.*cos(temp_theeta_incident));

p = [A.^2 2*A.*C-1 2*A.*B+C.^2+D 2*B.*C B.^2];
r= roots(p);

For the above code i get the following error:

??? Error using ==> diag
Out of memory. Type HELP MEMORY for your options.

Error in ==> roots at 61
a = diag(ones(1,n-2,class(c)),-1);

Error in ==> root_calculation at 26
r= roots(p); %%computing roots of the equation inorder to find the refractive index

size(temp_rho) is 1 105600

Bye
From: Steven Lord on

"Snow White" <gulesaman(a)gmail.com> wrote in message
news:hsbkgd$7pu$1(a)fred.mathworks.com...
> Hello,
>
> I get the following problem in my code can someone help me out with this.
> Thank you.
>
> A=((sin(temp_theeta_incident).^2).*(1+temp_rho)-2.*temp_rho/(4.*temp_rho).*cos(temp_theeta_incident));
> B=((sin(temp_theeta_incident).^2).*(1+temp_rho))/(4.*temp_rho.*cos(temp_theeta_incident));
> C=(-2.*(sin(temp_theeta_incident).^2).*(1-temp_rho)+temp_rho)./(4.*temp_rho.*cos(temp_theeta_incident));
>
> p = [A.^2 2*A.*C-1 2*A.*B+C.^2+D 2*B.*C B.^2];
> r= roots(p);
>
> For the above code i get the following error:
>
> ??? Error using ==> diag
> Out of memory. Type HELP MEMORY for your options.

Assuming that D is a scalar (1-by-1) and that temp_theeta_incident is the
same size as temp_rho, this means you're trying to find the roots of a
polynomial of degree greater than _4 MILLION_.

Is that truly your intention? I'm guessing it is not. If it is not, you
need to explain what specifically you're trying to do so we can attempt to
determine how to do it without performing this ROOTS calculation.

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


From: Snow White on
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

"Steven Lord" <slord(a)mathworks.com> wrote in message <hsbksl$2dc$1(a)fred.mathworks.com>...
>
> "Snow White" <gulesaman(a)gmail.com> wrote in message
> news:hsbkgd$7pu$1(a)fred.mathworks.com...
> > Hello,
> >
> > I get the following problem in my code can someone help me out with this.
> > Thank you.
> >
> > A=((sin(temp_theeta_incident).^2).*(1+temp_rho)-2.*temp_rho/(4.*temp_rho).*cos(temp_theeta_incident));
> > B=((sin(temp_theeta_incident).^2).*(1+temp_rho))/(4.*temp_rho.*cos(temp_theeta_incident));
> > C=(-2.*(sin(temp_theeta_incident).^2).*(1-temp_rho)+temp_rho)./(4.*temp_rho.*cos(temp_theeta_incident));
> >
> > p = [A.^2 2*A.*C-1 2*A.*B+C.^2+D 2*B.*C B.^2];
> > r= roots(p);
> >
> > For the above code i get the following error:
> >
> > ??? Error using ==> diag
> > Out of memory. Type HELP MEMORY for your options.
>
> Assuming that D is a scalar (1-by-1) and that temp_theeta_incident is the
> same size as temp_rho, this means you're trying to find the roots of a
> polynomial of degree greater than _4 MILLION_.
>
> Is that truly your intention? I'm guessing it is not. If it is not, you
> need to explain what specifically you're trying to do so we can attempt to
> determine how to do it without performing this ROOTS calculation.
>
> --
> 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: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: Snow White on
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
>