Reputation: 117
I have the following matlab code:
messages_llr_matrix = sparse(ROW_NUM, COL_NUM);
for index = 1 : length(II)
messages_llr_matrix(II(index), JJ(index)) = ...
code_word_aprior_prob(JJ(index));
end
This code takes a vector and copies it, to a sparse matrix rows if the element in the matrix is not zero.
matlab tells me not to use indexing in the previous matlab code, because it makes it very slow.
I want to build the messages_llr_matrix
matrix in the following manner:
messages_llr_matrix = sparse(II,JJ,code_word_aprior_prob,ROW_NUM,COL_NUM);
This is not a solution that works.
Upvotes: 0
Views: 65
Reputation: 35175
The problem seems to be that in your latter code II(ind)
, JJ(ind)
and code_word_aprior_prob(ind)
should go together, but in your convention you need code_word_aprior_prob(JJ(ind))
.
Try calling
messages_llr_matrix = sparse(II,JJ,code_word_aprior_prob(JJ),ROW_NUM,COL_NUM);
Upvotes: 2