matlab - convert a column (of numbers) of a cell from number to string -



matlab - convert a column (of numbers) of a cell from number to string -

in matlab, have problem want sort cell w.r.t column of numbers. sortrows function doesn't work (i error:some cells in x contain non-scalar values , cannot sorted). suspect need convert column of numbers string type.

so question how can convert 1 column of cell type string?

edit:

first 4 rows of cell:

cell_1 = {' 1996q1' 0.009 0.009 54594; ' 1996q2' 0.011 0.013 54594; ' 1996q3' 0.010 0.010 54594} [k,i]=sortrows(cell_1,4);

you can grep column want utilize , sort in numerical context. see illustration below (i changed values in forth column show effect).

cell_1 = {' 1996q1' 0.009 0.009 54594; ' 1996q2' 0.011 0.013 54592; ' 1996q3' 0.010 0.010 54593}; [~,ind] = sort([cell_1{:,4}]) ind = 2 3 1 cell_2 = cell_1(ind,:) cell_2 = ' 1996q2' [1.1000e-002] [1.3000e-002] [54592] ' 1996q3' [1.0000e-002] [1.0000e-002] [54593] ' 1996q1' [9.0000e-003] [9.0000e-003] [54594]

matlab sorting cell-array

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -