Info
此问题已关闭。 请重新打开它进行编辑或回答。
trivial issue - matrix in for loop: failed to fill a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am growing more confident in Matlab, thanks to community support, but sometimes I feel stucked due to very silly issues, as per the following case:
matr_counts_per_chunk = zeros(120,2752);
for col= 1:length(tr_x_ch)
matr_mat_fil_non_bool_sigle_tr = resh_matr_mat_fil_non_bool(:,col);
matr_counts_per_chunk(:,col) = sum(reshape(matr_mat_fil_non_bool_sigle_tr,[],250),2);
end
the problem is: matr_counts_per_chunk is only correctly filled in the first iteration, then I get only zeros in every 2751 left columns. This mean the for loop is actiually doing nothing/not working except for the first call.
Any help will be appreciated
1 个评论
dpb
2023-4-29
It doesn't mean the loop "isn't working" at all; only that the results aren't what you were expecting. The problem is likely the data are zero elsewhere.
It isn't possible to diagnose anything without sample data and it's certainly not clear what the real underlying intent of the code is, but it looks most peculiar.
Reduce the problem size to one that is manageable to see what is going on (an 8-10 x 10-20 array is just as useful to test code logic as is something huge and yet is small enough that one can inspect the input and output to find out where the logic issue(s) is(are).
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!