![]() ![]() This has the same restriction, all the cell contents must have the same number of characters or the command will error. So as pointed at, if one of your cell contained Foo24 then the reshape command would error.Įdit: Or as Chris Luengo kindly mentionned in comment, a simpler command to get exactly the same result: > cell2mat(FooCellArray.') Mainly because they are not as flexible as strings, each line has to have the same number of elements. ![]() This result type is a char array, which are ok when they are simple vector but they get quite unwieldy once they are in 2D. I would like to convert this cell into a 3 dimensional matrix of size 8x454x900. Should be I have 10 cell which each cell contain data 5x2. ![]() If you MATLAB version is older AND if all the strings in the cell array have the same length, you could convert your cell array into a 2D character array: > reshape(cell2mat(FooCellArray),4,).'įor this one, transposition wouldn't really make sense. I have a cell that is 8x454 with each element in the cell containing a 900x1 matrix. How to convert matrix to cell array 5 years, 7 months ago I have matrix A 50x2 How to convert the data into cell array. Note the terminology of the result type, it is a string array. The UniformOutput parameter is set to 0 to instruct CELLFUN to encapsulate the. Convert array to cell array whose cells contain subarrays. You can transpose it if you want it as a column instead of line vector. This function is applied to each cell in the A array/matrix using ARRAYFUN. This MATLAB function divides array A into smaller arrays and returns them in cell array C. The benefit of this method is that it will work even if the strings contained in your cell array are not all of the same length. convert numbers from text string cell-array C into a numerical matrix X. You can directly use the function convertCharsToStrings: > convertCharsToStrings(FooCellArray) Convert cell arrays element-wise (cellfun). With a smaller starting example: FooCellArray = ![]()
0 Comments
Leave a Reply. |