Divide column 17 of table by 365
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
xander fong
el 30 de Jul. de 2015
Respondida: Peter Perkins
el 30 de Jul. de 2015
Hello, I have a 1500x15 table, how do I divide every element in the 15th column by 365? Or, how do I create a new column which is column 15 divided by 365?
0 comentarios
Respuesta aceptada
Sean de Wolski
el 30 de Jul. de 2015
Editada: Sean de Wolski
el 30 de Jul. de 2015
y = x{:,15}./365
x{:,16} = y
2 comentarios
Sean de Wolski
el 30 de Jul. de 2015
Sorry, typo. It needs to be {} instead of () to extract from the table. See fix above.
Más respuestas (1)
Peter Perkins
el 30 de Jul. de 2015
More directly:
x.Var15 = x.Var15 / 365 % or whatever the 15th var is named
or
x.Var16 = x.Var15 / 365 % or whatever the new 16th var should be named
table brace subscripting is most useful for multiple variables, while the dot is more clear when there's only one.
Dividing by 365 sounds like a leap year bug just waiting to happen. Should you be using the calendar calculations built into datetime and calendarDuration?
0 comentarios
Ver también
Categorías
Más información sobre Tables 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!