フィルターのクリア

get a subcell from a bigger cell

8 ビュー (過去 30 日間)
Miguel Reina
Miguel Reina 2018 年 2 月 5 日
コメント済み: Jan 2018 年 2 月 5 日
I have a cell of 10x9 named 'a', each index contains a string. How can i create a sub cell if i have two vectors (f,c) with the indexes that i want. e.g. imagine a 2x3 cell a and indexes f and c
a={('this'), ('is') ,('big');('he') ,('buys') ,('it')}
f=[1,1,2];
c=[1,2,3];
the result i want is b={('this'), ('is');('it'),('')}
  3 件のコメント
Miguel Reina
Miguel Reina 2018 年 2 月 5 日
the indexes are found following a 2x3 matrix said
b=[1 1 0;0 0 1]
in which 1 indicates the "correct" words following a criteria. so to find the indexes of those words i used
[c,f]=find(b==1);
Jan
Jan 2018 年 2 月 5 日
Wouldn't it be easier to apply directly:
a(b)

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

回答 (1 件)

Guillaume
Guillaume 2018 年 2 月 5 日
Use ind2sub:
a(ind2sub(size(a), f, c))
The result will be 1x3 vector not an arbitrary sized array.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by