Filter löschen
Filter löschen

Form a matrix with specific day types

1 Ansicht (letzte 30 Tage)
pavlos
pavlos am 9 Feb. 2014
Beantwortet: Azzi Abdelmalek am 9 Feb. 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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 9 Feb. 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,:)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by