squeeze function returning "NaN"
Mostra commenti meno recenti
Hello everyone,
I'm trying to run a correlation between a 8, 8, 33 matrix (FC_mat) and a 33, 1 matrix, therefore, I'm trying to use the 'squeeze' function on the 8, 8, 33 matrix:
for regNum1=1:8;
for regNum2=1:8;
input1=FC_mat(regNum1,regNum2,:);
FC_mat_squeeze=squeeze(input1);
end
end
"FC_mat_squeeze=squeeze(input1);" is returning a 33, 1 matrix of all "NaN". There are NaN values along the diagonal of the "FC_mat" matrix.
I appreciate any insight any of y'all might have on getting the squeeze function to ignore the NaN's in the input.
Thanks!
Risposte (1)
Paul
il 6 Apr 2022
0 voti
squeeze() can't ignore anything. If the input to squeez() is 1 x 1 x 33 matrix of NaN, the ouptut will be 33 x 1 of NaN. What is the desired result if input1 is 1 x 1 x 33 of NaN?
5 Commenti
Julia Laing
il 6 Apr 2022
Paul
il 6 Apr 2022
I'm assuming that val is the same as FC_mat, and that each page of val has the same structure with NaN on the diagonal. The first time through the loops, regNum1 = regNum2 = 1, so input1 will be FC_mat(1,1,:), which will be a 1 x 1 x 33 of NaN. Is that not the case?
Julia Laing
il 6 Apr 2022
Paul
il 6 Apr 2022
The only ways that come to mind would be to replace the NaN's with actual numbers, or modify the loops so as not to process those elements, or to detect the NaN's and skip that processing, like this:
for regNum1=1:8;
for regNum2=1:8;
input1=FC_mat(regNum1,regNum2,:);
FC_mat_squeeze=squeeze(input1);
if ~any(isnan(FC_mat))
% process valid data
end
end
end
Julia Laing
il 6 Apr 2022
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!