- 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
1 view (last 30 days)
Show older comments
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 Comments
Jan
on 16 May 2022
The question is not clear:
Please post more details.
Accepted Answer
dpb
on 16 May 2022
Edited: dpb
on 16 May 2022
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'}
>>
More Answers (1)
Voss
on 16 May 2022
Edited: Voss
on 16 May 2022
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 Comments
dpb
on 17 May 2022
@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???
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!