フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to find character data in cell array and write in single column

2 ビュー (過去 30 日間)
Vishal Sharma
Vishal Sharma 2017 年 6 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (1 件)

Jan
Jan 2017 年 6 月 25 日
編集済み: Jan 2017 年 6 月 25 日
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.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by