Divide column 17 of table by 365
조회 수: 6 (최근 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에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!