MATLAB: Reading cell array from excel table, which contains different sizes of doubles cell arraydoubleimporting excel dataxlsread I would like to read these columns as cell arrays, where the components are doubles, such as the following: m_con = {[1,2,3],2,3}; I have tried xlsread but it didn't work. Best Answer There might be a smoother method but this works with the data from your image. file = 'Book1.xlsx';opts = detectImportOptions(file);opts = setvartype(opts, 'char'); C = readcell(file,opts); % you can also try readtable()numIdx = cellfun(@isnumeric,C); C(numIdx) = cellfun(@num2str,C(numIdx),'UniformOutput',false);Cnum = cellfun(@str2num,C,'UniformOutput',false)Cnum = 3×4 cell array {1×3 double} {1×3 double} {[ 1]} {[ 1]} {[ 2]} {[ 2]} {1×2 double} {1×2 double} {[ 3]} {[ 2]} {1×2 double} {1×2 double}Cnum{1,1}ans = 1 2 3 Related SolutionsMATLAB: How to transpose a cell array reshape command works for this example well. For poly as the name of the cell array, polyre = reshape(poly,[1 8]); MATLAB: Round in a cell array that also contains string idx = cellfun(@isnumeric,C);C(idx) = cellfun(@(x)round(x,N),C(idx),'uni',0) Related QuestionChoose 2 random unique element inside cellNeat stacking of array and cell arrayFind and convert characters in cell array to numeric values
Best Answer