How to label of CSV files

조회 수: 5 (최근 30일)
Kong
Kong 2020년 4월 8일
편집: Kong 2020년 4월 8일
Hello.
I am using CSV files.
In this code, I read CSV files and adjust the row and column.
I want to label the data.
(bend - 0, jack - 1, jump - 2, pjump - 3, run - 4, side - 5, skip - 6, walk - 7, wave1 - 8 , wave2 - 9)
I'm just using this code to label, but I have to change the value because of different files.
A = [ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17) ones(1,17) 17*ones(1,17) 3*ones(1,17) 4*ones(1,17) 5*ones(1,17) 6*ones(1,17) 7*ones(1,17) 8*ones(1,17) 9*ones(1,17) 10*ones(1,17)]';
Can I get some ideas to fix this code?
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);
Data = cell2mat(c);

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by