如何根据矩阵的某一列值的不同将矩阵进行分割并命名。
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
极速百家乐网址【微8785092】
le 18 Mai 2023
Réponse apportée : 百家乐真人网址网站【微8785092】
le 18 Mai 2023
大家好,我现在有一个矩阵,已经按第一列和第二列的升序进行了排序,现在我想通过第一列数值大小的不同将矩阵分成单独的几个不同的矩阵,要怎么样才可以实现呢,例如:[45 2 3;45 3 3;45 4 8; 47 2 1;47 3 6;47 4 9;51 2 8;51 3 6;51 4 7]分成单独的[45 2 3;45 3 3;45 4 8],[47 2 1;47 3 6;47 4 9],[51 2 8;51 3 6 ;51 4 7]并把分出来的三个矩阵按45 47 51进行命名呢。谢谢大家
0 commentaires
Réponse acceptée
百家乐真人网址网站【微8785092】
le 18 Mai 2023
仅供参考
A=[45 2 3;45 3 3;45 4 8;
47 2 1;47 3 6;47 4 9;
51 2 8;51 3 6;51 4 7];
index=unique(A(:,1));
for i=1:length(index)
mid = find(A(:,1)==index(i));
B = A(mid,:);
eval(['m',num2str(index(i)),'=','B']);
end
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!