Prev: For loop problem
Next: Vectorize AR Stochastic Process
From: Richard on 13 Aug 2010 08:30 Hi I have a system of linear equations(that I've finally vectorized.).I need to solve the following for P but I'm lost as to how to extract P from the vectorized formula to solve. I've put it on 3 lines for readability. Not even sure if I'm providing enough info here? Any help appreciated! Thanks SIRtarget and eta are scalar values U is an n*1 column G and X are n*m matrices P is a row of length m SIRtarget.*(repmat(U,1,length(G(1,:))).*G)'*(sum(repmat(P,length(X(:,1)),1).*(X./G),2))-SIRtarget.*P' +SIRtarget*eta*ones(length(G(1,:)),1) -P' here is the same formula in loop form so its more readable: for j=1:length(A) msum=0; for h=1:n s=0; for t=1:m s=s+(P(t)*X(h,t)/G(h,t)); end msum=msum+U(h)*G(h,j)*s; end A(j)=msum; end SIRtarget.*A - SIRtarget.*P' + SIRtarget.*eta - P'
From: Richard on 13 Aug 2010 10:44 "Richard " <REMOVETHISrcaldwellie(a)yahoo.com> wrote in message <i43dss$863$1(a)fred.mathworks.com>... > Hi I have a system of linear equations(that I've finally vectorized.).I need to solve the following for P but I'm lost as to how to extract P from the vectorized formula to solve. I've put it on 3 lines for readability. Not even sure if I'm providing enough info here? > Any help appreciated! > Thanks > SIRtarget and eta are scalar values > U is an n*1 column > G and X are n*m matrices > P is a row of length m > > SIRtarget.*(repmat(U,1,length(G(1,:))).*G)'*(sum(repmat(P,length(X(:,1)),1).*(X./G),2))-SIRtarget.*P' > +SIRtarget*eta*ones(length(G(1,:)),1) > -P' > > here is the same formula in loop form so its more readable: > > for j=1:length(A) > msum=0; > for h=1:n > s=0; > for t=1:m > s=s+(P(t)*X(h,t)/G(h,t)); > end > msum=msum+U(h)*G(h,j)*s; > end > A(j)=msum; > end > SIRtarget.*A - SIRtarget.*P' + SIRtarget.*eta - P' No answers? Am I trying to do something impossible or is my post just too hard to read?
From: Greg Heath on 13 Aug 2010 20:27 On Aug 13, 10:44 am, "Richard " <REMOVETHISrcaldwel...(a)yahoo.com> wrote: > "Richard " <REMOVETHISrcaldwel...(a)yahoo.com> wrote in message <i43dss$86....(a)fred.mathworks.com>... > > Hi I have a system of linear equations(that I've finally vectorized.).I need to solve the following for P but I'm lost as to how to extract P from the vectorized formula to solve. I've put it on 3 lines for readability.. Not even sure if I'm providing enough info here? > > Any help appreciated! > > Thanks > > SIRtarget and eta are scalar values > > U is an n*1 column > > G and X are n*m matrices > > P is a row of length m > > > SIRtarget.*(repmat(U,1,length(G(1,:))).*G)'*(sum(repmat(P,length(X(:,1)),1).*(X./G),2))-SIRtarget.*P' > > +SIRtarget*eta*ones(length(G(1,:)),1) > > -P' > > > here is the same formula in loop form so its more readable: > > > for j=1:length(A) > > msum=0; > > for h=1:n > > s=0; > > for t=1:m > > s=s+(P(t)*X(h,t)/G(h,t)); > > end > > msum=msum+U(h)*G(h,j)*s; > > end > > A(j)=msum; > > end > > SIRtarget.*A - SIRtarget.*P' + SIRtarget.*eta - P' > > No answers? Am I trying to do something impossible or is my post just too hard to read Where is your system linear equations? I am looking for something that looks like A*x = b Hope this helps. Greg
|
Pages: 1 Prev: For loop problem Next: Vectorize AR Stochastic Process |