Split increasing vector into n unqueal parts based on multiples of n

4 vues (au cours des 30 derniers jours)

Hi,
I have a vector which consists of increasing numbers.
I want to split the vector into 54 parts based on multiples of 2030. So first vector should contain all numbers from 0 until 2030. Second vector should contain all numbers from 2030 and up until 2*2030 (4060), third vector everything from 4060 up until 3*2030 (6090), etc.
Vector is attached.
Thanks.

  1 commentaire
Dyuman Joshi
Dyuman Joshi le 18 Sep 2023
load('Denc.mat')
m=max(Denc)
m = 115279
m/2030
ans = 56.7877
You want to ignore the 55th, 56th and the 57th parts?
Also, just to confirm, you want to include the boundary values on both sides?

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 18 Sep 2023
S = load('Denc.mat');
D = S.Denc
D = 5660×1
0 0 0 0 0 0 0 0 0 0
B = 0:2300:2300+max(D)
B = 1×52
0 2300 4600 6900 9200 11500 13800 16100 18400 20700 23000 25300 27600 29900 32200 34500 36800 39100 41400 43700 46000 48300 50600 52900 55200 57500 59800 62100 64400 66700
X = discretize(D,B);
C = accumarray(X,D,[],@(a){a})
C = 51×1 cell array
{1116×1 double} { 60×1 double} { 51×1 double} { 51×1 double} { 60×1 double} { 58×1 double} { 43×1 double} { 36×1 double} { 32×1 double} { 30×1 double} { 30×1 double} { 30×1 double} { 32×1 double} { 35×1 double} { 39×1 double} { 41×1 double}

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by