How to access induvidual elements in a string

I have a many strings of format "xhrs ymin".
where x and y are numbers
i want to store x and y in separate integers.
how do i do it?

댓글 수: 1

Is your array datetime? If yes look into hms()

답변 (1개)

Stephen23
Stephen23 2019년 6월 15일

0 개 추천

The simplest and most efficient solution is to use sscanf:
>> S = '23hrs 45min';
>> V = sscanf(S,'%fhrs%fmin')
V =
23
45

이 질문은 마감되었습니다.

질문:

2019년 6월 15일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by