divide every numeric value in table by same number

26 ビュー (過去 30 日間)
Davindra Usov
Davindra Usov 2023 年 3 月 26 日
コメント済み: Walter Roberson 2023 年 3 月 30 日
HI,
I want to divide every numeric value in my table by the same number but some columns have strings and some have numbers. I want to convert every number in the table from cm to m (but not the strings of course)
thanks

採用された回答

Walter Roberson
Walter Roberson 2023 年 3 月 26 日
divisor = 2;
T = table(["hello"; "orange"], [1;3], [2; 4])
T = 2×3 table
Var1 Var2 Var3 ________ ____ ____ "hello" 1 2 "orange" 3 4
vt = vartype('numeric')
vt =
table vartype subscript: Select table variables matching the type 'numeric' See Access Data in a Table.
T{:,vt} = T{:,vt} / divisor
T = 2×3 table
Var1 Var2 Var3 ________ ____ ____ "hello" 0.5 1 "orange" 1.5 2
  3 件のコメント
Walter Roberson
Walter Roberson 2023 年 3 月 30 日
@Siddharth Bhutiya -- thanks, that looks useful!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by