Matlab的sum函數(shù)可以對一維向量甚至多維向量進行求和運算,下面小編就給大家分享一下如何使用。
首先打開Matlab編輯軟件,如下圖所示,在軟件中我們創(chuàng)建一個一維的向量

接下來直接調(diào)用sum函數(shù)將創(chuàng)建的向量傳入進來,我們看到值立馬計算出來了,如下圖所示

接下來我們創(chuàng)建一個三維的向量,如下圖所示,注意每一維度用分號隔開

然后又同樣的將三維向量傳入sum函數(shù)中,sum函數(shù)會自動為我們計算值,如下圖所示
