2017-08-29 96 views
2

我有一個名爲「variable」的結構,其結構如下。使用結構體內的負值

  1. 向量的每個字段內都有一些負值。我想保持價值,但要積極。

  2. 做一個新的變量說v11(一個1633X1雙),具有明智的元素平均的領域。

enter image description here

回答

2

使用absstructfun到值轉換爲正數。然後使用struct2cell並水平連接單元格內容以應用mean並將結果分配給新字段v11

variable = structfun(@abs,variable,'un',0); 
v11= struct2cell(variable); 
variable.v11=mean([v11{:}],2); 
+0

感謝您的快速回答! –