Filtering column 2 and keeping column 1
Afficher commentaires plus anciens
I'm having an issue with filtering out data from column 2 that is below a certain desired output, but still keeping the time from column 1 to plot. I am fairly new to MatLab and it won't get rid of the negative outputs either.
This is my current code.
fs = 15;
rawData = xlsread('Total 4 Foot Lamp Lifecycle Testing.xlsx');
filteredData = lowpass(rawData(:,2),8,fs);
Any help is appriciated. Thank you.
Réponses (1)
Walter Roberson
le 14 Mai 2025
mask = filteredData >= THRESHHOLD;
selected_time = rawData(mask,1);
selected_filtered_data = filteredData(mask);
However, if you proceed to
plot(selected_time, selected_filtered_data)
then plot() is going to draw right across the gaps. If your purpose is to plot and you want gaps in the plot, then you are better off using
mask = filteredData < THRESHHOLD;
filteredData(mask) = nan;
time = rawData(:,1);
plot(time, filteredData);
This inserts NaN in place of data that is below the threshold. When you go to plot() then plot() knows to leave gaps at all non-finite values (so gaps at NaN, at -inf, and at +inf)
Catégories
En savoir plus sur Signal Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!