How to label of CSV files

4 次查看(过去 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 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by