필터 지우기
필터 지우기

Divide column 17 of table by 365

조회 수: 15 (최근 30일)
xander fong
xander fong 2015년 7월 30일
답변: Peter Perkins 2015년 7월 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?

채택된 답변

Sean de Wolski
Sean de Wolski 2015년 7월 30일
편집: Sean de Wolski 2015년 7월 30일
y = x{:,15}./365
x{:,16} = y
  댓글 수: 2
xander fong
xander fong 2015년 7월 30일
Doesn't work. "Undefined operator './' for input arguments of type 'table'."
Sean de Wolski
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
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?

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by