Separate one column of in a multi-column, (which is itself a cell array) into two columns in the existing cell array
1 ビュー (過去 30 日間)
表示 古いコメント
I have an application that reads data (from someone else's code), in a cell array with 8 columns. Here is a snipped of the first 9 rows:
9×8 cell array
Columns 1 through 6
{'E100M000.txt'} {'6109'} {'23-Sep-2020 14:…'} {[0.04]} {1×2 cell} {[4]}
{'E100M001.txt'} {'6109'} {'23-Sep-2020 14:…'} {[0.05]} {1×2 cell} {[4]}
{'E100M002.txt'} {'4781'} {'23-Sep-2020 15:…'} {[5.08]} {1×2 cell} {[0]}
{'E100M003.txt'} {'4717'} {'23-Sep-2020 15:…'} {[3.36]} {1×2 cell} {[0]}
{'E100M004.txt'} {'4781'} {'23-Sep-2020 15:…'} {[5.04]} {1×2 cell} {[0]}
{'E100M005.txt'} {'6051'} {'23-Sep-2020 16:…'} {[5.08]} {1×2 cell} {[0]}
{'E100M006.txt'} {'4167'} {'23-Sep-2020 15:…'} {[ 3.6]} {1×2 cell} {[0]}
{'E100M007.txt'} {'6022'} {'23-Sep-2020 15:…'} {[0.26]} {1×2 cell} {[0]}
{'E100M008.txt'} {'6002'} {'23-Sep-2020 16:…'} {[2.92]} {1×2 cell} {[0]}
Columns 7 through 8
{[2971.6]} {'Pleasant Valley…'}
{[3523.4]} {'Pleasant Valley…'}
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'251 Creek Road' }
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'23 Plateau Road' }
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'Peckham Propert…'}
Column 5 is itself a cell array, and I would like to replace this with two columns in a new cell array of everything. Column 5 has a letter in the first column of the array, and a number in the second. Simple to split this? reshape? split? ???
Wish I could get it in the right format in the first place, no such luck.
Thanks!
Doug Anderson
1 件のコメント
Arif Hoq
2022 年 3 月 23 日
as you did not attach your data, you can try this
% A is your cell array
col5=A{:,5}
out=horzcat(A(:,1),A(:,2),A(:,3),A(:,4),col5,A(:,6),A(:,7),A(:,8),A(:,9))
採用された回答
Voss
2022 年 3 月 24 日
C = { ...
'E100M000.txt' '6109' '23-Sep-2020 14:…' 0.04 {'A' 1} 4 2971.6 'Pleasant Valley…'; ...
'E100M001.txt' '6109' '23-Sep-2020 14:…' 0.05 {'B' 2} 4 3523.4 'Pleasant Valley…'; ...
'E100M002.txt' '4781' '23-Sep-2020 15:…' 5.08 {'C' 3} 0 0 'Peckham Propert…'}
C_new = [C(:,1:4) vertcat(C{:,5}) C(:,6:end)]
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!