Multiplying two variables in a table together

How would you multiply two variables/columns together from a table together, to create a new variable/column?
Lets say for example you have the following table:
Time Voltage Current
_____ _____ _____
1 8 2
2 9 4
3 6 6
And you want to multiply voltage and current together at each sample.
So you'd end up with a 4th column/variable called power that is voltage multiplied by current at each time interval

 採用された回答

Voss
Voss 2024 年 3 月 5 日

1 投票

T.Power = T.Voltage.*T.Current;
where T is your table.

3 件のコメント

Voss
Voss 2024 年 3 月 5 日
Running your example:
Time = [1;2;3];
Voltage = [8;9;6];
Current = [2;4;6];
T = table(Time,Voltage,Current)
T = 3×3 table
Time Voltage Current ____ _______ _______ 1 8 2 2 9 4 3 6 6
T.Power = T.Voltage.*T.Current
T = 3×4 table
Time Voltage Current Power ____ _______ _______ _____ 1 8 2 16 2 9 4 36 3 6 6 36
AluminiumMan
AluminiumMan 2024 年 3 月 5 日
This worked. Thank you
Voss
Voss 2024 年 3 月 5 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

リリース

R2023b

質問済み:

2024 年 3 月 5 日

コメント済み:

2024 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by