- What is a "cell of 1*3430 character"?
- What does "acqusition time for 245 files" exactly mean?
- What is "stored in continuous manner"?
- What is the type and size after "convert it into a column"?
- With which code did you try the trim function?
- What was the error message?
cell of characters to column
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a cell of 1*3430 character consisting of acqusition time for 245 files. (one time value is of 14 charachters stored in continuous manner).
i want to convert it into a column. i tried using trim function but there was some error everytime.
these values would be input to another function so getting these values are essential hence looking for help in this regards.
댓글 수: 2
Jan
2022년 5월 16일
The question is not clear:
Please post more details.
채택된 답변
dpb
2022년 5월 16일
편집: dpb
2022년 5월 16일
We need to see this in situ -- how did you get it into such a form, first.
Attach the file from whence the data came (or a representative sample thereof) and/or a .mat file of the data.
While it's probably possible to avoid having to do so by reading the data in correctly, if they are fixed-length strings, then
t=cellstr(reshape(s,14,[]).');
will give you an Nx14 cellstr array to pass or convert.
Example, dummy data--
>> s='A':'z'; s=s(1:end-2) % make up a string with mod(14) characters...
s =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx'
>> strlength(s)
ans =
56
>>
Apply the engine...
>> t=cellstr(reshape(s,14,[]).')
t =
4×1 cell array
{'ABCDEFGHIJKLMN'}
{'OPQRSTUVWXYZ[\'}
{']^_`abcdefghij'}
{'klmnopqrstuvwx'}
>>
추가 답변 (1개)
Voss
2022년 5월 16일
편집: Voss
2022년 5월 16일
It's not clear whether you have (Case 1) a cell array of characters, like this:
times_cell_char = {'0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '1' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '2' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '3' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '4'}
Or (Case 2) a cell array of character vectors, like this:
times_cell = {'00000000000000' '00000000000001' '00000000000002' '00000000000003' '00000000000004'};
Or (Case 3) a single character vector, like this:
times_char = '0000000000000000000000000001000000000000020000000000000300000000000004';
It's also not clear what you want the result to be.
If the result should be a character array, you can do one of these things:
Case 1:
times = reshape([times_cell_char{:}],14,[]).'
Case 2:
times = char(times_cell.')
Case 3:
times = reshape(times_char,14,[]).'
If the result should be a (column) cell array of character vectors, you can do one of these things:
Case 1:
times = cellstr(reshape([times_cell_char{:}],14,[]).')
Case 2:
times = times_cell.'
Case 3:
times = cellstr(reshape(times_char,14,[]).')
댓글 수: 2
dpb
2022년 5월 17일
@Arvind Gauns, I'd still ask/am curious how you got such data into such a format in the beginning so that you had to split it this way. It would seem could avoid that in the beginning???
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!