Search code examples
stringmatlabcell-array

Operating on a vector of cells and inseriting it into a cell array MATLAB


What I'm working with is a cell array M, with say nxm cells. I read in column d, colD, to edit the strings contained therein.

I changed these cells using char(colD), and now have a vector of strings that I'm done editing. Converting back to cells using cell(colD) I need to insert the vector into the cell array. Is there a more efficient way of doing it than looping?

Thank you in advance!


Solution

  • I think what you want is:

    newM = cellfun(@(x) char(x), M, 'UniformOutput', false)
    

    shamelessly stolen from @Ansari