Info

This question is closed. Reopen it to edit or answer.

How to access induvidual elements in a string

1 view (last 30 days)
Vikram Aditya
Vikram Aditya on 15 Jun 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
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?

Answers (1)

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

Community Treasure Hunt

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

Start Hunting!