Effacer les filtres
Effacer les filtres

Form a matrix with specific day types

1 vue (au cours des 30 derniers jours)
pavlos
pavlos le 9 Fév 2014
Hello,
Please help me with the following.
I have a matrix with dates as entries in the form:
01/01/2013 2 a
01/02/2013 3 b
01/03/2013 4 c
etc.
The right side digits denote the type of day, "1" is for Monday, "2" for Tuesday, "3" for Wednesday etc. and "a", "b" and "c" are values that are recorded in the specific dates.
How can I extract all the Mondays of the year with the respective values in a seperate matrix?
The new matrix should have the form:
01/07/2013 1 aa
01/14/2013 1 ab
01/21/2013 1 ac
etc.
Thank you very much. Best,
Pavlos

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 9 Fév 2014
M={'01/01/2013' 2 'a'
'01/02/2013' 3 'b'
'01/03/2013' 4 'c'
'01/01/2013' 2 'a'
'01/02/2013' 2 'b'
'01/03/2013' 4 'c'}
day=2;
idx=ismember(cell2mat(M(:,2)),day)
out=M(idx,:)

Plus de réponses (0)

Catégories

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