0
我有以下matlab代码,我想用no写for循环: 代码将满足一定条件的assings值赋给稀疏矩阵。二,JJ是稀疏矩阵索引。向量化一些matlab代码
all_tanh_bits = ones(1, NUMBER_OF_EQ);
%Calculating each equation multipicative factor.
for index = 1 : length(II)
all_tanh_bits(II(index)) = (all_tanh_bits(II(index)) * ...
tanh(messages_matrix(II(index), JJ(index))/2));
end
for index = 1 : length(II)
%not_relevant_mul is the elemnt to divide - so the
%current node only uses other message nodes for
%calculating the llr.
not_relevant_mul = tanh(messages_matrix(II(index), ...
JJ(index))/2);
check_matrix_mul = all_tanh_bits(II(index))/not_relevant_mul;
check_matrix(II(index), JJ(index)) = ...
log((1 + check_matrix_mul)/(1 - check_matrix_mul));
end
另一个for循环呢? – yaron
好吧,如果你明白我为第一个写的是什么,那么直接使用'。/'向量化第二个。但通过再次查看你的第一个循环,我不确定你在这里试图做什么 - 你用1乘以一些东西? – Yugong
我尝试了您的建议,但似乎没有奏效:/您能否给我一些其他解决方案。我得到错误,维度不同意。 – yaron