Divide column 17 of table by 365
15 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sean de Wolski
2015-7-30
编辑:Sean de Wolski
2015-7-30
y = x{:,15}./365
x{:,16} = y
2 个评论
Sean de Wolski
2015-7-30
Sorry, typo. It needs to be {} instead of () to extract from the table. See fix above.
更多回答(1 个)
Peter Perkins
2015-7-30
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!