how to keep certain rows value in specific columns

1 次查看(过去 30 天)
  • I have a t matrix with 10 rows
  • 1 0 1 1 0
  • 1 1 0 0 0
  • 0 1 1 0 1
  • 1 0 1 0 1
  • 1 1 1 0 0
  • 0 0 1 1 0
  • 0 0 1 1 0
  • 1 1 0 0 1
  • 1 1 1 1 1
  • 1 1 0 0 1
row 1 and 2 is assumed to be part a
row 3 and 4 as part b
row 5 and 6 as part c
row 7 and 8 as part d
row 9 and 10 as part e
codes matrix is a 32 by 32 matrix. after performing xor operation such that row 1 is xor with first 16 bits (i.e 1 to 16) of codes and stored in 1 to 16 bits of out matrix
and row 2 with next 16 (i.e 16 to 32) bits of codes and stored in 16 to 32 bits of out matrix. please help me in how to should I proceed with it.
  • t = randi(0:1,1,5); -------------------------> generating random binary data in 10 rows
  • N = 16; ---------------------------------------> generating hadamard matrix to have a matrix with codes to be used for xor operation with t matrix
  • hadamardmat = hadamard(N);
  • codeTx1 = hadamardmat(:,1);
  • codeTx2 = hadamardmat(:,2);
  • codeTx3 = hadamardmat(:,3);
  • codeTx4 = hadamardmat(:,4);
  • codeTx5 = hadamardmat(:,5);
  • codeTx6 = hadamardmat(:,6);
  • codeTx7 = hadamardmat(:,7);
  • codeTx8 = hadamardmat(:,8);
  • code_Tx9 = hadamardmat(:,9);
  • code_Tx10 = hadamardmat(:,10);
  • code_Tx11 = hadamardmat(:,11);
  • code_Tx12 = hadamardmat(:,12);
  • code_Tx13 = hadamardmat(:,13);
  • code_Tx14 = hadamardmat(:,14);
  • code_Tx15 = hadamardmat(:,15);
  • code_Tx16 = hadamardmat(:,16);
  • allcodes = [codeTx1 codeTx2 codeTx3 codeTx4 codeTx5 codeTx6 codeTx7 codeTx8 code_Tx9 code_Tx10 code_Tx11 code_Tx12 code_Tx13 code_Tx14 code_Tx15 code_Tx16];
  • codes_p = allcodes;
  • allcodes_p(codes_p == -1) = 0;
  • s=codes_p;
  • no_oftags = 10;
  • out = zeros(no_oftags,16); ---------------------------------> following for loop in this manner
  • for n = 1:no_oftags
  • out(n,:) = xor(t(1,n),codes_p(n,:)); -------------------------> xor operation of t matrix and codes matrix
  • end
  1 个评论
Geoff Hayes
Geoff Hayes 2019-4-14
Ayesha - I don't understand why you create the individual code_Tx arrays (the columns of hadamardmat) which you then just use to create a new matrix allcodes which is presumably identical to hadamardmat... Also, since each row of t has five columns, how do you want to xor this data with a row of allcodes which has sixteen elements per row? How should we then get a 32x32 matrix from all of this?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by