write number next to each other + return value 0/1

2 ビュー (過去 30 日間)
Zuzana Pániková
Zuzana Pániková 2022 年 6 月 14 日
コメント済み: Zuzana Pániková 2022 年 6 月 17 日
Hello,
i have a tablehave imported from Excel.
In the ID column I want the values ​​from hod + min + s + CasVSekundach but as text so that it doesn't add up for me (T.ID = (T.hod) + (T.min) + (T.s). It should look like in the first column: not 25 but 002525(h/min/s/CasVSekundach).
And I want to create a new column (ID_H), where the distance from the column according to criterion> 5 returns 0 and if = <5 returns 1
I try ID_H=(ID(ID>5)=1), but it doesn´t works...
Thank you for any help.
  1 件のコメント
ILoveMATLAB
ILoveMATLAB 2022 年 6 月 14 日
編集済み: ILoveMATLAB 2022 年 6 月 15 日
For your first question.
  1. Convert each column of intrest to an array of strings. sCol1 =strings(T.hod)
  2. Concatenate all the strings arrays using the + operator T.ID = sCol1 + sCol2+ sCol3
For your second question
ID_H = double(ID>5);

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

採用された回答

Jon
Jon 2022 年 6 月 14 日
Let us say your table is called T, then you can use:
T.ID = string(T.hod) + string(T.min) + string(T.s) + string(CasVSekundach)
  8 件のコメント
Zuzana Pániková
Zuzana Pániková 2022 年 6 月 17 日
Sorry, I didn't understand the principle of the example attachment here on the site.
Zuzana Pániková
Zuzana Pániková 2022 年 6 月 17 日
T.ID = string(T.hod) + string(T.min) + string(T.s)+(T.CasVSekundach)
I got it, I'm slow. Thanks a lot for your help.

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

その他の回答 (1 件)

ILoveMATLAB
ILoveMATLAB 2022 年 6 月 15 日
編集済み: ILoveMATLAB 2022 年 6 月 15 日
(Forgot to submit as an anwser)
For your first question.
  1. Convert each column of interest to an array of strings. sCol1 =strings(T.hod)
  2. Concatenate all the strings arrays using the + operator T.ID = sCol1 + sCol2+ sCol3
For your second question
ID_H = double(ID>5);
  4 件のコメント
Walter Roberson
Walter Roberson 2022 年 6 月 16 日
Zuzana Pániková
Zuzana Pániková 2022 年 6 月 17 日
Thank you,now it works

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by