How to reduce the code (csvread, reshape, concatenate matrix)?
Show older comments
Hello.
I wanna reduce the below code to use several other folders. in particular, how to read files without each reading.
1. read file in the folder
2. reshape several rows to one row
3. extracting data for the same length
4. concatenate matrix
5.Add a label at the end
clear all
close all
% read file in fold
A = csvread('bend/daria_bend_geo01.csv');
B = csvread('bend/denis_bend_geo01.csv');
C = csvread('bend/eli_bend_geo01.csv');
D = csvread('bend/ido_bend_geo01.csv');
E = csvread('bend/ira_bend_geo01.csv');
F = csvread('bend/lena_bend_geo01.csv');
G = csvread('bend/lyova_bend_geo01.csv');
H = csvread('bend/moshe_bend_geo01.csv');
I = csvread('bend/shahar_bend_geo01.csv');
% reshape several rows to one row
A=reshape(A,[],1);
B=reshape(B,[],1);
C=reshape(C,[],1);
D=reshape(D,[],1);
E=reshape(E,[],1);
F=reshape(F,[],1);
G=reshape(G,[],1);
H=reshape(H,[],1);
I=reshape(I,[],1);
% extracting data for same length
A=A(1:1568,:);
B=B(1:1568,:);
C=C(1:1568,:);
D=D(1:1568,:);
E=E(1:1568,:);
F=F(1:1568,:);
G=G(1:1568,:);
H=H(1:1568,:);
I=I(1:1568,:);
% concatenate matrix
bend = [A.';B.';C.';D.';E.';F.';G.';H.';I.']
% Add a label at the end
0 or 1
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!