Loop to replace a NaN matrix with specific data from another matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Francis Trombini
am 23 Mai 2021
Kommentiert: Francis Trombini
am 24 Mai 2021
How could I use a loop to replace a NaN matrix (1 line x 30 columns) with specific data from another matrix? My interest is to replace the values of the matrix 'CI_mean_X_ForStatistic_VarNames' with the values of the matrix 'CI_mean_X_VarNames', skipping 10 columns each time in the loop. Thanks in advance for the help.
This my long code.
CI_mean_X_ForStatistic_VarNames_NaN = NaN(1,30); % first, creating a NaN matrix (1 line x 30 columns) to insert the variable names sorted regarding the scale factor order of each condition, side by side.
CI_mean_X_ForStatistic_VarNames = num2cell(CI_mean_X_ForStatistic_VarNames_NaN);
CI_mean_X_ForStatistic_VarNames(:,1) = CI_mean_X_VarNames (:,1);
CI_mean_X_ForStatistic_VarNames(:,2) = CI_mean_X_VarNames (:,11);
CI_mean_X_ForStatistic_VarNames(:,3) = CI_mean_X_VarNames (:,21);
CI_mean_X_ForStatistic_VarNames(:,4) = CI_mean_X_VarNames (:,2);
CI_mean_X_ForStatistic_VarNames(:,5) = CI_mean_X_VarNames (:,12);
CI_mean_X_ForStatistic_VarNames(:,6) = CI_mean_X_VarNames (:,22);
CI_mean_X_ForStatistic_VarNames(:,7) = CI_mean_X_VarNames (:,3);
CI_mean_X_ForStatistic_VarNames(:,8) = CI_mean_X_VarNames (:,13);
CI_mean_X_ForStatistic_VarNames(:,9) = CI_mean_X_VarNames (:,23);
CI_mean_X_ForStatistic_VarNames(:,10) = CI_mean_X_VarNames (:,4);
CI_mean_X_ForStatistic_VarNames(:,11) = CI_mean_X_VarNames (:,14);
CI_mean_X_ForStatistic_VarNames(:,12) = CI_mean_X_VarNames (:,24);
CI_mean_X_ForStatistic_VarNames(:,13) = CI_mean_X_VarNames (:,5);
CI_mean_X_ForStatistic_VarNames(:,14) = CI_mean_X_VarNames (:,15);
CI_mean_X_ForStatistic_VarNames(:,15) = CI_mean_X_VarNames (:,25);
CI_mean_X_ForStatistic_VarNames(:,16) = CI_mean_X_VarNames (:,6);
CI_mean_X_ForStatistic_VarNames(:,17) = CI_mean_X_VarNames (:,16);
CI_mean_X_ForStatistic_VarNames(:,18) = CI_mean_X_VarNames (:,26);
CI_mean_X_ForStatistic_VarNames(:,19) = CI_mean_X_VarNames (:,7);
CI_mean_X_ForStatistic_VarNames(:,20) = CI_mean_X_VarNames (:,17);
CI_mean_X_ForStatistic_VarNames(:,21) = CI_mean_X_VarNames (:,27);
CI_mean_X_ForStatistic_VarNames(:,22) = CI_mean_X_VarNames (:,8);
CI_mean_X_ForStatistic_VarNames(:,23) = CI_mean_X_VarNames (:,18);
CI_mean_X_ForStatistic_VarNames(:,24) = CI_mean_X_VarNames (:,28);
CI_mean_X_ForStatistic_VarNames(:,25) = CI_mean_X_VarNames (:,9);
CI_mean_X_ForStatistic_VarNames(:,26) = CI_mean_X_VarNames (:,19);
CI_mean_X_ForStatistic_VarNames(:,27) = CI_mean_X_VarNames (:,29);
CI_mean_X_ForStatistic_VarNames(:,28) = CI_mean_X_VarNames (:,10);
CI_mean_X_ForStatistic_VarNames(:,29) = CI_mean_X_VarNames (:,20);
CI_mean_X_ForStatistic_VarNames(:,30) = CI_mean_X_VarNames (:,30);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 23 Mai 2021
%demonstration for tracing
CI_mean_X_VarNames = 1 : 30
%the work
CI_mean_X_ForStatistic_VarNames = reshape(reshape(CI_mean_X_VarNames, [], 3).', 1, [])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!