# How to sum values of two cell arrays based on another array?.

9 ビュー (過去 30 日間)
lucksBi 2018 年 1 月 8 日
コメント済み: Birdman 2018 年 1 月 8 日
Hey all
How to sum values of Add1 with all elements of Add2 based on ConditionArray.
conditionArray = {[2,3,4,5];[1,3,4,5]}
Result will be based on ConditionArray. Like As ConditionArray{1,1} contains [2,3,4,5] which means that we have to take 2nd,3rd,4th and 5th value from Add1 and add up these values with Add2{1,1}. Similarly ConditionArray{2,1} contains [1,3,4,5] which means that we have to take 1st,3rd,4th and 5th value from Add1 and add up these values with Add2{1,2}. Result may look like this:
ResultantArray{1,1} = {1,1.8,-0.4,0.8,-0.2} % {(1+0),(1+0.8),(0.6+(-1)),(0.6+0.2),(0.3+(-0.5))}
ResultantArray{1,2} = {1.6,1,1.8,1.6,0.6} % {(1.6+0),(1+0),(1+0.8),(0.6+1),(0.6+0)}

サインインしてコメントする。

### 採用された回答

Birdman 2018 年 1 月 8 日
%conversion
%taking necessary values
%resultant array
##### 4 件のコメント表示非表示 3 件の古いコメント
Birdman 2018 年 1 月 8 日
If you want to include that number as well, then change the index to
[1 3 4 5 6]

サインインしてコメントする。

### カテゴリ

Find more on Matrix Indexing in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by