removing samples from a timeseries between certain time intervals

27 views (last 30 days)
Hi there!
I have a large amount of timeseries (voltage, current, power, etc.) collected from a smart grid simulation. Every 900 seconds there is a spike in all of the values for only a fraction of a second. I know it would probably be easier to fix the cause of the spikes instead of doing it this way, but assuming the cause of the spikes is unfixable, is there a way to remove all samples of a timeseries in between a certain time interval?
This way I can set the interval to a little before every multiple of 900s and a little after 900s and fix the problem this way.
It has to be noted that I used a variable solver to run the simulation in Simulink, so the timeseries doesn't have fixed timestamps and the amount of timestamps differ from timeseries to timeseries.
I will attach a picture below where you can see the problem.
All help would be greatly appreciated!
Kind Regards
Alexander

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 28 May 2021
Hi Alexander,
The answers to you posed questions as follows in the order of your questions:
(1) Remove specific timeseries:
T = ttot; % All time series
IND = (1:10:length(T)); % Select and keep every 11th value. You can choose whichever value needed
Tnew = T(IND);
Y = Ytot;
Ynew = Y(IND); % Newly reselected or downsampled signbal values
In your Simulink model you can set up odesolver's settings to fixed-step solver and you will get fixed number of solutions/simulation values. By default, the solver setting is a variable step solver.
Good luck.
  3 Comments
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 28 May 2021
Just deleting specific set of data is quite simple, e.g:
T(899:900) = [];
Fixed vs. flexible option depends on one's exercise type. I don't know the simulation time constraints and accuracy tolerances of your exercise, and thus, you need to simulate, verify and choose the right one.
Good luck.
Alexander Van Waeyenberge
Alexander Van Waeyenberge on 28 May 2021
The code given deleted the timestamps with index 899 to 900.
I am more specifically looking to delete the timestamps between second 899 and second 900 for example. As I have to use a variable solver, it's not as simple unfortunately
Thanks for your help though!
Kind regards

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!