Search code examples
arraysmatlabcellsqrt

Square root of cell array in matlab


I have a cell array A={<2x6 double>,<4x6 double>,<16x6 double>} and I want to calculate the square root of all elements of this cell array. for a single matrix, it is so simple to use sqrt but for cell array, is there any solution? THX in advance


Solution

  • Try arrayfun:

    B = arrayfun(@(i) sqrt(A{i}), 1:length(A), 'Uni', 0);