필터 지우기
필터 지우기

Extracting a section of data with conditions/limits

조회 수: 1 (최근 30일)
Taylor Swaim
Taylor Swaim 2022년 2월 17일
답변: Abolfazl Chaman Motlagh 2022년 2월 17일
I have two data sets that correspond with one another:
altitude = [0; 1; 2; 3; 4; 5]
time = [08:05; 08:06; 08:07, 08:08, 08:09; 08:10]
I want to extract the section between time=08:06 and time=08:09 and it's corresponding altitude

채택된 답변

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022년 2월 17일
altitude = [0; 1; 2; 3; 4; 5];
time = ['08:05'; '08:06'; '08:07'; '08:08'; '08:09'; '08:10'];
hours = str2num(time(:,1:2));
minutes = str2num(time(:,4:5));
flag = and(minutes>6,minutes<9);
desired_data = table(altitude(flag) , time(flag,:) , 'VariableNames',{'Altitudes','Time'})
desired_data = 2×2 table
Altitudes Time _________ _____ 2 08:07 3 08:08
if your time in general could be more complex, convert it to minutes (or seconds) then create flag vector:
minutes = hours*60 + minutes ;
flag = and(minutes>485,minutes<489); % 08:05 is 485 minutes, 08:09 is 489 minutes

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by