How can i divide data into equal parts?
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
shubham shubham
il 24 Nov 2020
Commentato: shubham shubham
il 25 Nov 2020
Suppose we have data from 1:1:100.... I want to divide it such that one variable have data r1=1:1:25 another r2= 26:1:50, r3= 51:1:75 and r4= 76:1:100 .... How can i do this dynamically so I can access r1 in first iteration of loop r2 in second and so on..?
0 Commenti
Risposta accettata
Stephen23
il 24 Nov 2020
V = 1:100;
C = mat2cell(V,1,[25,25,25,25]);
C{1} % C{2}, etc.
5 Commenti
Stephen23
il 25 Nov 2020
Modificato: Stephen23
il 25 Nov 2020
V = 1:100; % data
B = 4; % required number of blocks
N = numel(V);
X = N*ones(1,B)/B
Of course if N is not exactly divisible by B then you will need to decide on how to split the data into differently-sized blocks, possibly using linspace or rounding or similar.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!