필터 지우기
필터 지우기

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