How to reshape each matrix of cell

조회 수: 10 (최근 30일)
Kong
Kong 2020년 4월 4일
댓글: Kong 2020년 4월 4일
Hello.
I want to reshape each matrix of cell.
Using this code, I got the cell matrix. How can I reshape the matrix (1325 x180) to (25 x 9540)?
clear all
close all
% Create the list of csv files
s = dir('*.csv');
% Read from each csv file
c = cell(numel(s),1 );
for kk = 1:numel(s )
filePath = fullfile(s(kk).folder,s(kk).name );
x = csvread(filePath );
c{kk} = x;
end
% Find the minumul number of row and column
row = cellfun(@(x) size(x,1),c );
col = cellfun(@(x) size(x,2),c );
minRow = min(row );
minCol = min(col);
% Adjust the size of each array to minRow-by-minCol
c = cellfun(@(x) x(1:minRow,1:minCol),c,'UniformOutput',false);
% How to reshape (1325 x180) to (25 x 9540) ?

채택된 답변

David Hill
David Hill 2020년 4월 4일
for k=1:length(c)
c{k}=reshape(c{k},25,9540);
end
  댓글 수: 1
Kong
Kong 2020년 4월 4일
Thank you so much!.
After reshaping the matrix, How can I flatten the each matrix?
It's not working.
c = reshape(c,1,[])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by