Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Better way to generate a matrix
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Milos Milenkovic

Posts: 164
Registered: 4/4/09
Better way to generate a matrix
Posted: Jan 27, 2014 2:11 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear,
how to get the same result for L14 (obtained by Method 1, which have to be modified for various lengths of Pih vector), but now by including variable length of input Pih vector (Method 2)?

Method 1
N=3;
P=3;
Pih1=[25 15 10];
L11=repmat(Pih1(1),N,N-1);
L12=repmat(Pih1(2),N,N-1);
L13=repmat(Pih1(3),N,N-1);
L14=blkdiag(L11, L12, L13);

Method 2
for i=1:length(Pih1)
L00=repmat(Pih1(i),N,N-1)
L0=blkdiag(L00, L00, L00)
end

Thanks.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.