Hi, this is a formula for m linear equations where I need to solve for P where P is a vector of m values. Its written here in loop form and I've vectorised it below to solve in matlab
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
for j=1:m
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'
Vectorised for matlab as(split onto 5 lines for readability):
SIRtarget.*(repmat(U,1,length(G(1,:))).*G)'*(sum(r epmat(P,length(X(:,1)),1).*(X./G),2))-SIRtarget.*P'
+SIRtarget*eta*ones(length(G(1,:)),1)
-P'
=0;
Problem is I cant figure out how to extract P from the vectorised formula to pass the linear equations to linsolve(Matlab). It needs to be vectorised as P could be up to 50 or 60 values long. G and X will typically be 400 rows X 50 or 60 columns.
Original formula attached as jpg
Any help much appreciated
Thanks
Richard


LinkBack URL
About LinkBacks
