Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
How to find character data in cell array and write in single column
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
A cell array has following character data
A{1,1}=[' '] [' '] ['Smith'] [' '] ; ['False'] [' '] [' '] [' '] ; [' '] [' '] [' '] ['Allen'] ;
I want to identify data in each row and write in one column, so as to get output
A{1,1} = ['Smith'] ; ['False'] ; ['Allen'];
Thanks
0 Commenti
Risposte (1)
Jan
il 25 Giu 2017
Modificato: Jan
il 25 Giu 2017
The shown code is not valid Matlab, such that I guess, you mean this:
A = {' ', ' ', 'Smith', ' ' ; ...
'False', ' ',' ', ' ' ; ...
' ', ' ', ' ', 'Allen'};
If this is correct, then:
B = A(~strcmp(A, ' '))
Perhaps the cell string is nested, then:
AA = A{1};
B = AA(~strcmp(AA, ' '));
On demand use reshape or B = B(:) to change the shape.
PS. Prefer to post the data such that the readers can reproduce them by a copy&paste to the command window.
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!