MATLAB: Reading data from cell array cell arraysMATLAB I have a cell array that contains all the data. A{1,1}, A{2,1},…A{37,1}. Now, I want to extract the first row from A{1,1}, A{2,1},…A{37,1} and then combine all the 37 rows in one mat file. How can I do that? Best Answer C = cell2mat(cellfun(@(x) x(1,:), A, 'un',0));save mymat.mat C Related SolutionsMATLAB: Combine a cell array of cell arrays to a single cell array NewCellArray = vertcat( ExistingCellArray{:} ); MATLAB: Reading data from csv files %your original code, slightly modifiedcsvfiles = dir('*.csv'); filescontent = cell(numel(csvfiles), 1);for i = 1:numel(csvfiles) filescontent{i} = csvread(csvfiles(i).name);end%write rows of matrices into mat filedestfolder = 'C:\somewhere\somefolder';allcontent = cat(3, filescontent{:}); %concatenate all matrices into a 3D matrix%save rows of each matrix into a mat file (as variable rows)for rowidx = 1:size(allcontent, 1) rows = permute(allcontent(rowidx, :, :), [3 2 1]); %extract rows.Permute so each matrix is a row of rows save(fullfile(destfolder, sprintf('row%d.mat', rowidx)), rows);end Related QuestionDelete empty [] {1×7 cell} {1×2 cell}Reading audioReading .mat filesExtracting data from nested cell.Reading text file
Best Answer