Load (xlsread) a especific time sample

조회 수: 4 (최근 30일)
Sérgio Querido
Sérgio Querido 2017년 3월 28일
댓글: Star Strider 2017년 3월 29일
In spreadsheet attached, how can i do a rotine to load (with xlsread) a especific time sample (example: 00:01:24 to 00:05:03)?

답변 (1개)

Star Strider
Star Strider 2017년 3월 29일
If your file is formatted the same as in Heart Rate by category, you cannot. You have to read the entire file, parse the column, Convert to the appropriate formats, then do the selections:
[~,sc] = xlsread('TEST.csv');
t_rc = regexp(sc(2:end), ';','split'); % Parse Column
dn = cellfun(@(x) datenum(x(:,1), 'HH:MM:SS'), t_rc); % Convert To Date Numbers
hr = cellfun(@(x) str2double(x(:,2)), t_rc); % Convert To Doubles
  댓글 수: 2
Sérgio Querido
Sérgio Querido 2017년 3월 29일
Ok!! Do you know the code to do the selection, after appropriate formats??
Star Strider
Star Strider 2017년 3월 29일
Yes!
The Code
[~,sc] = xlsread('Sérgio Querido TEST.csv');
t_rc = regexp(sc(2:end), ';','split'); % Parse Column
dn = cellfun(@(x) datenum(x(:,1), 'HH:MM:SS'), t_rc);
hr = cellfun(@(x) str2double(x(:,2)), t_rc);
dn_range = datenum(['00:01:24'; '00:05:03'], 'HH:MM:SS');
idx = find((dn >= dn_range(1)) & (dn <= dn_range(2)));
The ‘idx’ variable has the row indices for the times that meet the criteria.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by