Hi all
array1 = {[1,2,3,6,7,8];[1,2,6]}
array2 = {[3,6,7,8];[1,2,6]}
Remove = {[0.94,1,0.5,0.90,1,0.87];[1,0.9,1]}
Values in array1 corresponds to each value in 'Remove' e.g. 1 corresponds to 0.94, 2 corresponds to 1 and so on. In array2 i have removed some values from array1 based on a condition. Like 1,2 are removed from array1{1,1} where as no value is removed from array1{2,1} (result shown in array2)
Now I also need to remove corresponding values from 'Remove' which are removed from array1. Like 1,2 are removed from array1{1,1} so 0.94 and 1 will also be removed from 'Remove'. Result will look like this:
ResultantArray = {[0.5,0.90,1,0.87];[1,0.9,1]}
Please help.

 採用された回答

Birdman
Birdman 2018 年 1 月 3 日

0 投票

Consider you save the index of the first two values deleted from array1 as follows:
idx=find(array1{1,1}(1:2));
Then, delete the first two corresponding values from Remove as follows:
Remove{1,1}(idx)=[]

3 件のコメント

lucksBi
lucksBi 2018 年 1 月 3 日
編集済み: lucksBi 2018 年 1 月 3 日
Thank You. What if values deleted are 4 and 8. I mean not continuous as 1 and 2?
Birdman
Birdman 2018 年 1 月 3 日
Well, to generalize it, you may use ismember function as follows:
[~,idx]=find(ismember(array{1,1},[4,8]));
lucksBi
lucksBi 2018 年 1 月 3 日
Thanks alot.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

質問済み:

2018 年 1 月 3 日

コメント済み:

2018 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by