Multiply a scalar to all column of a table

149 次查看(过去 30 天)
I've a table, T. I want to mulitply a scalar to all values in the table (similary to scalar multiplication of a matrix e.g. 2*rand(5,5)).
I tried 10*T, it doesn't work.
Any suggestions?

采纳的回答

Bhaskar R
Bhaskar R 2020-2-3
编辑:Bhaskar R 2020-2-3
Suppose T is your table variable with it's variable name Var1
T.Var1 = 10*T.Var1;
  4 个评论
JZ
JZ 2020-3-26
I believe can also use T{:, :} = T{:, :} .* 10
Steven Lord
Steven Lord 2020-3-26
If all the variables in your table can be concatenated together:
T.Variables = 10*T.Variables;
If they can't, you can use varfun with the 'InputVariables' parameter set to something like @isnumeric to operate only on the variables that are numeric (and so for which it makes sense to multiply by a number.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by