Connecttwo lines of code to one
Show older comments
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:)
Answers (1)
t1 = datetime('now','TimeZone','local','Format',' HH:mm:ss ') ;
t2 = datetime('now','TimeZone','local','Format',' HH:mm:ss ') ;
data = [t1,t2] ;
iwant = minute(data(1))
4 Comments
Shahar ben ezra
on 20 Oct 2022
David Hill
on 20 Oct 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
on 20 Oct 2022
Edited: Shahar ben ezra
on 20 Oct 2022
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];
x=minute(data(1))%here are the two lines combined to one!
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!