Convert an array of strings to a cell

I need to output a cell to an excel file. Before that, I need to convert the integer date column to datestrings. I know how to do this, but I cannot return this new array of strings to a cell -

mycell = { 'AIR' [780] [1] [734472] [0.01] ; ...
           'ABC' [780] [1] [734472] [0.02]}

I did it →

dates = datestr(cell2mat(mycell(:,4))) ;

What I need as an answer:

{'AIR' [780] [1] '14-Dec-2010' [0.01] ;
 'ABC' [780] [1] '23-Dec-2010' [0.03] ; }

so now i can send it to excel file using xlswrite.m

+3
source share
2 answers
mycell = { 'AIR' 780 1 734472 0.01] ; ...
           'ABC' 780 1 734472 0.02]}

mycell(:,4) = cellstr(datestr(cell2mat(mycell(:,4))))

mycell = 

    'AIR'    [780]    [1]    '30-Nov-2010'    [0.01]
    'ABC'    [780]    [1]    '30-Nov-2010'    [0.02]
+3
source

One option to avoid conversions is to use the CELLFUN function :

mycell(:,4) = cellfun(@datestr,mycell(:,4),'UniformOutput',false);
%# Or an alternative format...
mycell(:,4) = cellfun(@(d) {datestr(d)},mycell(:,4));

Both of the above give the following result for your array of cells:

mycell = 

    'AIR'    [780]    [1]    '30-Nov-2010'    [0.0100]
    'ABC'    [780]    [1]    '30-Nov-2010'    [0.0200]
+1
source

Source: https://habr.com/ru/post/1782799/