How to concatenate cell array with blank

13 views (last 30 days)
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.

Accepted Answer

Oleg Komarov
Oleg Komarov on 26 May 2012
cs = {'ob' '^b' [] '$b'};
idx = cellfun('isempty',cs);
cs = cs(~idx);

More Answers (2)

Karthik KJ
Karthik KJ on 26 May 2012
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 Comment
Oleg Komarov
Oleg Komarov on 26 May 2012
~ is the negation operator.
try in your command window:
~index
index
Then it should be clear what to use to get 'mean'.

Sign in to comment.


Karthik KJ
Karthik KJ on 27 May 2012
thank you oleg. two negation operator can provide as you said. string(~~index)
  1 Comment
Oleg Komarov
Oleg Komarov on 27 May 2012
Or you can simply remove the tilde and simple use index.

Sign in to comment.

Categories

Find more on Structures 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!