how to split and transpose a cell array?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Viridiana Torres
am 29 Apr. 2016
Kommentiert: Viridiana Torres
am 30 Apr. 2016
Hi !! I have the next cell composition (30*1 size)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162939/image.jpeg)
What I want to do is to split it first, according to the "," so each different number has to occupy a diffierent column. Like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162940/image.jpeg)
After this, I want to transpose all the numbers, so I want to have a final matrix size (7*30)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162941/image.jpeg)
Can anyone help me to solve this?
Thanks in advance!
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 29 Apr. 2016
a={'12,13,14,45';'4,8,nan,nan';'450,2,14,nan'}
out=cell2mat(cellfun(@(x) str2num(strrep(x,',',' ')),a,'un',0))'
4 Kommentare
Azzi Abdelmalek
am 29 Apr. 2016
Bearbeitet: Azzi Abdelmalek
am 29 Apr. 2016
This is not a problem, you know how to transpose a matrix?
out=out'
Now, for your previous comment, please post an example. It seems that your data are not similar to my example.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!