如何根据行列和值生成矩阵?。
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
已知excel表中有3列4行矩阵A:
行 列 值
1 3 5 %意思是新矩阵第一行,第三列值为5
1 2 4
2 1 1
2 3 2
想要按照上面行列的号码和值生成新矩阵B:
0 4 5 %按照上面的excel表列、行作为位置坐标生成新矩阵,没有显示行列坐标和值的自动填充0
1 0 2
求赐教从A矩阵变为B矩阵的命令
0 Kommentare
Akzeptierte Antwort
defour
am 21 Mai 2023
仅供参考
A=[1,3,5;
1,2,4;
2,1,1;
2,3,2];
B=zeros(max(A(:,1)),max(A(:,2)));
[r,v] =size(A);
for i=1:r
B(A(i,1),A(i,2))=A(i,3);
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!