Hi!
How to connect the last two lines code to one
%%
clc; clear all; close all;
my_data = string('1,3,4,5,6,8')
t1 = datetime('now','TimeZone','local','Format',' HH:mm:ss ')
t2 = datetime('now','TimeZone','local','Format',' HH:mm:ss ')
data = [t1,t2]
pat = ":"
x = split((string(data(:,1))),pat) %this
x= double(x(2,1)) % and this
Tnx:)

Antworten (1)

KSSV
KSSV am 20 Okt. 2022
Bearbeitet: KSSV am 20 Okt. 2022

1 Stimme

t1 = datetime('now','TimeZone','local','Format',' HH:mm:ss ') ;
t2 = datetime('now','TimeZone','local','Format',' HH:mm:ss ') ;
data = [t1,t2] ;
data = 1×2 datetime array
15:27:11 15:27:11
iwant = 27
iwant = minute(data(1))

4 Kommentare

Shahar ben ezra
Shahar ben ezra am 20 Okt. 2022
The original code is more complicated and requires me to use these functions
The code here is an example
And so I want to combine the last two lines code
thank you for the answer, but this is not what i need
David Hill
David Hill am 20 Okt. 2022
You make no sense. You need to change your example to resemble your problem more coompletely. The above solution is perfect for your current example.
Shahar ben ezra
Shahar ben ezra am 20 Okt. 2022
Bearbeitet: Shahar ben ezra am 20 Okt. 2022
I want to connect these two lines in one line of code
Why doesn't it make sense?
I am not interested in any other solution
I know it can be solved in an easier way
But it's different from my original code where it can't be done
clc; clear all; close all;
my_data = string('1,3,4,5,6,8')
my_data = "1,3,4,5,6,8"
t1 = datetime('now','TimeZone','local','Format',' HH:mm:ss ')
t1 = datetime
19:18:25
t2 = datetime('now','TimeZone','local','Format',' HH:mm:ss ')
t2 = datetime
19:18:25
data = [t1,t2];
x=minute(data(1))%here are the two lines combined to one!
x = 18

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2021a

Gefragt:

am 20 Okt. 2022

Kommentiert:

am 20 Okt. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by