Loop to replace a NaN matrix with specific data from another matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2021-5-23
%demonstration for tracing
CI_mean_X_VarNames = 1 : 30
%the work
CI_mean_X_ForStatistic_VarNames = reshape(reshape(CI_mean_X_VarNames, [], 3).', 1, [])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!