I have grid frequency data, first column is time(Time) and second is frequency (Value). I want to calculate the duration of each cycle between 50 to 49.90 Hz.
Show older comments
data = readtable("2023-01-01.csv");
Freq = data.Value;
Time = datetime(data.Time);
logind = [false; Freq<=50 & Freq >=49.90 ; false];
cyclestart = strfind(logind', [false true]);
cycleend = strfind(logind', [true false]);
cycleDurations = zeros(size(cyclestart));
what happen when the last value is 50.1 or something?
%% i = 1:length(cyclestart)
startTime = Time(cyclestart(i));
endTime = Time(cycleend(i)-1);
cycleDurations(i) = seconds(endTime - startTime);
1 Comment
Alexander
on 27 Mar 2024
What is your question? It would be helpful to supply the csv also.
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Measurements 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!