How I can split a two column data into chunks like this snap shot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have attached a mat file and I want to chunk my data in equal number of arrays like the attached image. Since I am dealing with a large data set of around 200 files of data and I have to do this iteration for every file and plot it. so kindly guide me and help me in chunking and plotting automatically as currently i am doing it manually with every file and using excel tool for data chunking and plotting.
Looking forward to your comments.

0 Kommentare
Akzeptierte Antwort
Voss
am 24 Okt. 2023
S = load('Data_Chunking.mat');
A = S.Alg2_mLat_maxEE;
C = 9; % chunk size
[M,N] = size(A);
% in case A is not an integer number of chunks tall,
% append A with rows of NaNs to make it an integer
% number of chunks tall
m = mod(M,C);
if m
A = [A; NaN(C-m,N)];
M = M+C-m;
end
% now do the chunking:
A_chunked = reshape(permute(reshape(A(:,[2 1]),C,[],2),[1 3 2]),C,[]);
% make a table out of the chunked matrix (may be easier to see/deal with):
T = array2table(A_chunked,'VariableNames',["Number of Iterations";"Value"]+(1:M/C));
disp(T);
0 Kommentare
Weitere Antworten (1)
Fabio Freschi
am 24 Okt. 2023
If I have understood correctly, this code should to the job. Note that 83 is a prime number, so it is difficult to create chunks. I have kept the first 80 rows
load('Data_Chunking.mat');
% remove three rows to make it "chunkable"
A = Alg2_mLat_maxEE(1:80,:);
% number of rows per chunk
N = 5;
% reshape to have N rows
B = reshape(permute(reshape(A,N,[],2),[1 3 2]),N,[])
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!