Effacer les filtres
Effacer les filtres

extract each ten values

5 vues (au cours des 30 derniers jours)
Housam
Housam le 14 Juil 2019
Commenté : Housam le 15 Juil 2019
Hello,
I have a 60x23 cell and each cell consist of columns with different length.
I need to extract ten values starting from last ten values, then shift by one value and repeat.
In other words, after extacting the last ten values (end-9: end), i need to omit the last value. then extract the ten values before that. so on.
What would be the best way to achieve that? Thank you for the insights.
  1 commentaire
dpb
dpb le 14 Juil 2019
As described, probably a loop just recomputing the indices.
It's not clear, however, whether this is a moving-by-one element process or in groups of ten non-overlapping elements--the end objective could possibly be accomplished for either of those by far more efficient manners -- filter for the first, perhaps, or reshape by the 10 factor by columns for the latter for vector processing by column.
"It all depends..."
Give us a concrete example of what you're really after...

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 14 Juil 2019
Try a loop to get the contents of the cells in your cell array, then extract 10 elements and move back towards the beginning of your vector one element at a time.
[rows, columns] = size(ca); % ca is your cell array with variable sized matrices in the cells.
for col = 1 : columns
for row = 1 : rows
% Get the array inside this cell from the cell array.
thisVector = ca{row, col};
% Get the size of this vector
vecCols = length(thisVector);
% Get last 10 values and move one element at a time towards the beginning of the vector.
len = length(vecCols);
for k = len - 9 : -1 : 1
last10 = vecCols(k : k+9);
% Now do something with last10.....
% I don't know what that would be - you haven't told us.
end
end
end
  1 commentaire
Housam
Housam le 15 Juil 2019
Thank you! this is what i was looking for.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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