Delete all data points from the structure
2 views (last 30 days)
i would like to delete all data points from the time series for which the following condition is true :
(temp < 2) & (speed < 1)
my_structure = 1 * 3 struct
the structure contains 4 fields : date, temp, speed and power
i used the following code but it didn't work:
temp_data = [my_structure.temp]
speed_data = [my_structure.speed]
for i = 1:size(my_structure, 2)
j = 1:length(temp_data)
to_remove = or((temp_data(j,i) < 2 ) , (speed_data(j,i) < 1))
if to_remove(j) == 1
to_remove(j) = 
Reshma Nerella on 4 Apr 2021
From my understanding, you want to certain datapoints in the structure satisfying either of the two conditions i.e (temp < 2) & (speed < 1).
To acheive this, you can modify your code as follows:
for i = 1:size(my_structure,2)
if(my_structure(i).temp < 2) % check if the temp value is 2 is that particular row of struct
my_structure(i).temp = ; % if yes, set it to .
if(my_structure(i).speed < 1)
my_structure(i).speed = ;
Hope this helps!