Thanks, Roger. Yes, unfortunately I'm interested in all the rows of B. If i had to run this once, I wouldn't even bother, but the loop is called millions of times by an optimization function. Anyway, I appreciate your help.
Best,
Mariano
"Roger Stafford" wrote in message <j9rgmc$237$1@newscl01ah.mathworks.com>...
> "Mariano" wrote in message <j9pd6e$6ov$1@newscl01ah.mathworks.com>...
> > I have the following forloop:
> > for n=1:N1
> > Baux = B(n,:);
> > A(n+1) = A(n) + Baux*mhu + Baux*sigma*Baux';
> > B(n+1,:) = Baux*theta delta;
> > end
> >
> > where B(1,:) and A(1) are given
> > Matrix B is 120x60
> > Matrix A is 120x1
> > mhu is 60x1
> > sigma is 60x60, theta is 60x60
> > delta is 1x60
> > N = 120
> >
> > Is there any way to speed this up? Like some clever vectorization that I can't figure out?
> > I can actually solve for B in closed form and write it as an inline function of n but i doubt it will be faster
> > Any suggestions? Thank you!
> >
> > Mariano
>        
> I assume your "closed form" is
>
> B(n,:) = (B(1,:)delta/(thetaeye(60)))*V*D^(n1)*V' ...
> + delta/(thetaeye(60)) ;
>
> where theta = V*D*V' is the eigenvector/eigenvalue decomposition of theta. This might be an effective shortcut for evaluating just B(120,:) alone, but if you need all the B(n,:) values, I suspect that your forloop is about as efficient a method as you can find. To apply the above closed form to each value of n would obviously be less efficient.
>
> Roger Stafford
