How to concatenate cell array with blank

6 ビュー (過去 30 日間)
Karthik KJ
Karthik KJ 2012 年 5 月 26 日
Hi, can anyone help me in concatenating below cell array
{'ob' '^b' [] '$b'}
so that output will be
{'ob' '^b' '$b'}
this is an dynamic output so i could not identify the exact position of blank. Is there any simple method available otherwise i have to use a loop to identify the blank.

採用された回答

Oleg Komarov
Oleg Komarov 2012 年 5 月 26 日
cs = {'ob' '^b' [] '$b'};
idx = cellfun('isempty',cs);
cs = cs(~idx);
  1 件のコメント
Karthik KJ
Karthik KJ 2012 年 5 月 26 日
Thank you Oleg

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

その他の回答 (2 件)

Karthik KJ
Karthik KJ 2012 年 5 月 26 日
Hi Oleg, if i have index=[1;0;0] and string={'mean' 'min' 'max'}. As per index my output should be 'mean', how to get this. string(~index) gives ''min'' and ''max''. what is the sign to be used for getting ''mean''
  1 件のコメント
Oleg Komarov
Oleg Komarov 2012 年 5 月 26 日
~ is the negation operator.
try in your command window:
~index
index
Then it should be clear what to use to get 'mean'.

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


Karthik KJ
Karthik KJ 2012 年 5 月 27 日
thank you oleg. two negation operator can provide as you said. string(~~index)
  1 件のコメント
Oleg Komarov
Oleg Komarov 2012 年 5 月 27 日
Or you can simply remove the tilde and simple use index.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by