Multiplying a column in a table by a constant

Hello,
I need to multiply a one-column table by e^-9. I don't know MATLAB code, so this is new to me. How can I do this please, any help would be appreciated.
Thank you,
Tim

 채택된 답변

Walter Roberson
Walter Roberson 2023년 8월 17일
편집: Walter Roberson 2023년 8월 18일

0 개 추천

YourTableName.NameOfColumn = YourTableName.nameOfColumn * 1e-9;
The above is the recommended form.
If, for some reason, you do not know hte column name, but you know the column number, then
YourTableName.(ColumnNumber) = YourTableName.(ColumnNumber) * 1e-9;

댓글 수: 3

Timothy
Timothy 2023년 8월 18일
Thanks for the explanation!
Zachary
Zachary 2024년 9월 7일
I am trying to change units in my column. I want to go from mm to cm, so I just divide by 10. At the same time, I want to keep the original column value. How would you do that?
@Zachary: So you want to keep the existing column, which is in mm, and add a new column with the same quantities but in cm. Is that right? If so, here's an example:
values_in_mm = [1;2;3];
T = table(values_in_mm)
T = 3x1 table
values_in_mm ____________ 1 2 3
T.values_in_cm = T.values_in_mm/10
T = 3x2 table
values_in_mm values_in_cm ____________ ____________ 1 0.1 2 0.2 3 0.3

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

2023년 8월 17일

댓글:

2024년 9월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by