Create a new column in the table with conditional values ​​of 1 or 0

11 ビュー (過去 30 日間)
Zuzana Pániková
Zuzana Pániková 2022 年 5 月 22 日
コメント済み: Zuzana Pániková 2022 年 5 月 23 日
Hi,
I imported a spreadsheet from Excel to Matlab:
I need to create a new column where the condition evaluates from column G (Odstup_s_) so that all values ​​that are <= 5 will be 1 and the others will be 0
in excely it would look like: =IF(G2<5;1;0)
Thank you for help.

採用された回答

Jonas
Jonas 2022 年 5 月 22 日
編集済み: Jonas 2022 年 5 月 22 日
you could use
LLT.newVar=LLT{:,6}<=5
or
LLT.newVar=LLT.Odstub_s_<=5;
but i cannot see the whole variable name
of course you could use an other name instead of newVar for the table variable name
  2 件のコメント
dpb
dpb 2022 年 5 月 22 日
And as a nicety, one could use addvars to locate the column position in which to add the new variable if would be more appropriate somewhere besides adding it to the RH side.
Zuzana Pániková
Zuzana Pániková 2022 年 5 月 23 日
Thank you very much,it works great.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by