矩陣維度不一樣!!! 怎分別算長度??。
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
a=[1 2 3 4 5 6 4 5 6 7 6
3 4 5 6 ];
分求出每一行的長度(length)
行數是一個可變量 所以沒辦分行去算
請問網上各位有甚麼方法嗎??!
0 Kommentare
Akzeptierte Antwort
daxele
am 21 Nov. 2022
你的矩阵应该是a=[1 2 3 4 5 6 ; 4 5 6 7 6 0 ; 3 4 5 6 0 0 ];你的意思就是相当于统计每行非零数的个数;
B=abs(sign(a));
ind=sum(B,2)ind就是你计算的每行非0数,这样应该比循环的方法好,你可以跑下程序,循环你知道了行数,找每行的非0数应该也不难,可以参考我那个,只是变成向量而已。下回记得点回复我,要不我看不到,如果问题解决了,也请选择最佳答案
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!