matlab去掉零元素
作者:互联网
方法1:
a = [0,1,2,0,19,3,0,0];
b = a(find(a));
方法2:
[Matlab] 去除矩陣內的0元素
向量:>> a=[1,0,2,3,0,4,5]
a =
1 0 2 3 0 4 5
>> a(find(a==0))=[]
a =
1 2 3 4 5
矩陣:
>> a=[0 0;1 2;0 0;3 4]
a =
0 0
1 2
0 0
3 4
>> a(find(a==0))=[]
a =
1 3 2 4
>> a=reshape(a,2,2)
a =
1 2
3 4
标签:19,reshape,元素,find,matlab,去掉,矩陣 来源: https://www.cnblogs.com/yibeimingyue/p/16351643.html