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 vector
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Milos Milenkovic

Posts: 149
Registered: 4/4/09
Better way to generate a vector
Posted: Jan 25, 2014 5:45 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear,
please propose (if exists) some better way to fill in the vector Xp:
Thanks
N=2;
P=3;
T=4;
Sp=zeros(N,T);
Sp= [20 15 22 18; 17 16 18 22];
T1=[10 5 15 6;13 3 11 4];
T2=[11 3 14 2; 16 5 9 3];
T3=[13 1 11 3; 14 2 9 3];
T4=[18 5 12 4; 17 6 14 7];

Xp=zeros((N^2 + 2*N*(N-1)*(P-1))*T,1 );
Xp(1:N:N^2)=Sp(:,1);
Xp(N^2+4*N+1:N:2*N^2+4*N)=Sp(:,2);
Xp(2*N^2+8*N+1:N:3*N^2+8*N)=Sp(:,3);
Xp(3*N^2+12*N+1:N:4*N^2+12*N)=Sp(:,4);
Xp(N^2+1:N^2+2*N*(N-1)*(P-1))=T1(:,:);
Xp(2*N^2+2*N*(N-1)*(P-1)+1:2*N^2+2*2*N*(N-1)*(P-1))=T2(:,:);
Xp(3*N^2+2*2*N*(N-1)*(P-1)+1:3*N^2+3*2*N*(N-1)*(P-1))=T3(:,:);
Xp(4*N^2+3*2*N*(N-1)*(P-1)+1: end)=T4(:,:);



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.