# Exacting a constant range/window of values from a matrix (skipping one cell each time).

4 vues (au cours des 30 derniers jours)
Matt le 27 Oct 2022
Hi all,
I have a variable of values, X (1000 x 1) and want to create a separate variable, Y which is made up from values 1:24, skip one cell, then the next 24 values, skip one cell etc etc. until a certain value or the end of the matrix.
I feel like it should be reltively simple but just can't seem to quite get it right. Any help would be much appreciated.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

KALYAN ACHARJYA le 27 Oct 2022
data=rand(1000,1);
data(25:25:1000)=[];
temp=length(data)/24;
cell_data=mat2cell(data,24*ones(1,temp))
cell_data = 40×1 cell array
{24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double} {24×1 double}
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
KALYAN ACHARJYA le 27 Oct 2022
Each cell element consist of 24x1 values, the good way to handle multiple array is using cell array, as shown in the code.

Connectez-vous pour commenter.

### Plus de réponses (1)

RAGHUNATHRAJU DASHARATHA le 27 Oct 2022
As per my understanding you want to skip every 25th value of a matrix.
I will try to explain it using an example below .
A=1:1000;
B=A'
B = 1000×1
1 2 3 4 5 6 7 8 9 10
for i=1:38
B(i*25)=[];
end
output=B
output = 962×1
1 2 3 4 5 6 7 8 9 10
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Image Arithmetic dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by