Deleting range of rows in a time series data
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sewwandhi Chandrasekara
il 20 Giu 2024
Commentato: Sewwandhi Chandrasekara
il 1 Lug 2024
I have time series of rainfall data. The column 1=year, 2=month, 3=date (from 1 to 31), 4=daily rainfall value. I want to remove the rows which have range of data from year 1995 to 2016. I managed to do for one year. But not for range. How can I do so? Many thanks in advance.
RF(find(RF==1([1995:2016],:)=[] I did this code, but says error of using : inbetween 1995 & 2016
0 Commenti
Risposta accettata
Anurag Ojha
il 20 Giu 2024
Hey
To remove the rows with a range of years from 1995 to 2016, you can use logical indexing in MATLAB. Here's an example code snippet that demonstrates how to achieve this:
I have taken a simpler sample data, Kindly modify the code as per your use case:
% Sample data creation
% Columns: year, month, date, daily rainfall value
data = [
1990, 1, 1, 10;
1992, 5, 15, 5;
1995, 7, 21, 12;
2000, 2, 11, 8;
2010, 8, 23, 7;
2016, 12, 31, 20;
2017, 3, 14, 3;
2020, 6, 5, 15;
2022, 10, 19, 4;
];
% Display the original data
disp('Original Data:');
disp(data);
% Create a logical index for rows that fall outside the range 1995-2016
index = (data(:, 1) < 1995 | data(:, 1) > 2016);
% Remove the rows that satisfy the logical index
filtered_data = data(index, :);
% Display the filtered data
disp('Filtered Data:');
disp(filtered_data);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!