HOW CAN I MULTIPLY VALUES IN JUST ONE COLUMN?

20 ビュー (過去 30 日間)
Pul
Pul 2021 年 6 月 24 日
コメント済み: Pul 2021 年 6 月 24 日
Hi everyone,
I should multiply all the values of the column "Var4" for those values:" x10x0.5" ; how could I do it?
Thank you very much.
  4 件のコメント
Iñigo Escanciano
Iñigo Escanciano 2021 年 6 月 24 日
編集済み: Iñigo Escanciano 2021 年 6 月 24 日
In this case you have a timetable, which is a specific table type, but still a table. Therefore, you should check how to access data in tables.
In the link there are a lot of examples, you can choose whichever is best for you. I could simply give you one answer but getting it yourself is the best way as it is a basics question.
Pul
Pul 2021 年 6 月 24 日
Yes, you're right.
Thank you.

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

採用された回答

KSSV
KSSV 2021 年 6 月 24 日
It looks like you have a table. If T is your table and you want to multiply 3 and 4 th column.
iwant = T.(3).*T.(4) ; % .* <-- element by element multiplication
  4 件のコメント
Iñigo Escanciano
Iñigo Escanciano 2021 年 6 月 24 日
As what we are looking for is the 4th column variables, being stored in a table, you have 4 options:
Specifying the 4th column of your table
giulia_TT.(4) * 0.5 * 10
Specifying the column name
giulia_TT.Var4 * 0.5 * 10
Accessing it like a matrix (curly bracket indexing for tables)
giulia_TT{:,4} * 0.5 * 10
Mixed way, specifying the column name with curly bracket indexing
giulia_TT{:,'Var4'} * 0.5 * 10
Pul
Pul 2021 年 6 月 24 日
Got it.
Thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by