Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

trivial issue - matrix in for loop: failed to fill a matrix

2 visualizaciones (últimos 30 días)
Enzo
Enzo el 29 de Abr. de 2023
Cerrada: Cris LaPierre el 29 de Abr. de 2023
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 comentario
dpb
dpb el 29 de Abr. de 2023
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).

Respuestas (0)

La pregunta está cerrada.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by