フィルターのクリア

Appending one cell array to non-zero cells of another

2 ビュー (過去 30 日間)
Eli Dim
Eli Dim 2015 年 7 月 2 日
コメント済み: Eli Dim 2015 年 7 月 2 日
I have a cell array FINAL_OUTPUT < 50x1 cell > and another one called indexing as shown in the attached file. How can I append the indexing column inside the non-empty cells of FINAL_OUTPUT? In the end, I would like to have FINAL_OUTPUT{1,1} having size 3x3 FINAL_OUTPUT{2,1} having size < 1x3 > etc...and the empty cells of FINAL_OUTPUT should remain empty.
  3 件のコメント
Eli Dim
Eli Dim 2015 年 7 月 2 日
編集済み: Eli Dim 2015 年 7 月 2 日
Here is a sample set. Thank you for your assistance. The idea is that the rows of indexing should be appended to the non-zero rows of FINAL_OUTPUT
Eli Dim
Eli Dim 2015 年 7 月 2 日
these are the indices of FINAL_OUTPUT to which each row of indexing corresponds.

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

採用された回答

Stephen23
Stephen23 2015 年 7 月 2 日
編集済み: Stephen23 2015 年 7 月 2 日
>> out = cellfun(@(F,I)[F,num2cell(I)], FINAL_OUTPUT(check_not_empty), indexing, 'UniformOutput',false);
>> out{1}
ans =
'A' [ 110] [1]
'B' [ 110] [2]
'C' [2.8422e-14] [3]
>> out{2}
ans =
'A' [56.5000] [1]
>> out{3}
ans =
'A' [55] [1]
'B' [55] [2]
'C' [55] [3]
And of course to allocate back into the original cell array, just use indexing:
FINAL_OUTPUT(check_not_empty) = out;
  1 件のコメント
Eli Dim
Eli Dim 2015 年 7 月 2 日
thank you very much

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 2 日
out=cellfun(@(x,y) [x y],FINAL_OUTPU,indexing,'un',0)
  1 件のコメント
Eli Dim
Eli Dim 2015 年 7 月 2 日
Thank you for your answer, but this does not work since the arguments FINAL_OUTPUT and indexing are not of the same size.

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

カテゴリ

Help Center および File ExchangeSequence Alignment についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by