MATLAB 按條件進行加和

用 find 命令僅僅是找到元素的序號。數組

這裏使用sum 直接選取數組中的元素而後進行加和:spa

 

a=[1 2 3 4;5 6 7 8;9 8 7 6;5 4 3 2];
b=sum(a(a>=6));

 

 

 

相關文章
相關標籤/搜索