Borrar filtros
Borrar filtros

Form a matrix with specific day types

1 visualización (últimos 30 días)
pavlos
pavlos el 9 de Feb. de 2014
Respondida: Azzi Abdelmalek el 9 de Feb. de 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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by