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

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 Kommentar

ILoveMATLAB
ILoveMATLAB am 14 Jun. 2022
Bearbeitet: ILoveMATLAB am 15 Jun. 2022
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);

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jon
Jon am 14 Jun. 2022
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 Kommentare

Thanks you for your answer.
With hod,min and s works but with CasVSekundach deosn´t. CasVSekundach i created in matlab.
What shows up for
whos CasVSekundach T
Jon
Jon am 15 Jun. 2022
I'm not sure what you mean by " but with CasVSekundach deosn´t."
Please attach files to allow me to recreate the issue and explain further exactly what output you want and what errors or problems you are still having
Zuzana Pániková
Zuzana Pániková am 15 Jun. 2022
Bearbeitet: Zuzana Pániková am 15 Jun. 2022
I=imread(´vzorovymat.mat´)
imshow(I)
works it?
Jon
Jon am 15 Jun. 2022
Sorry, I don't understand
S = load('vzorvymat.mat')
S = struct with fields:
T: [12645×9 table] x3_5: [12645×7 table]
It is unclear why you want to IMREAD() a .mat file, or what you expect IMSHOW() to do with table data.
Sorry, I didn't understand the principle of the example attachment here on the site.
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

ILoveMATLAB
ILoveMATLAB am 15 Jun. 2022
Bearbeitet: ILoveMATLAB am 15 Jun. 2022
(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 Kommentare

Thank you for your answer, but i try it and matlab writed: Size vector should be a row vector with real elements.
by second: T.ID_H = double(odstup>5);
Unrecognized function or variable 'odstup'.
after i try: O=T(:,"odstup")
T.ID_H = double(O>5)
Operator '>' is not supported for operands of type 'table'.
I don't understand what your doing. What is odstup? You need to define the odstup variable.
%Try this
ID_H = double(T.ID>5);
%Or this
ID = T.ID
ID_H = double(ID>5);
Thank you,now it works

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by