filtering data with a for loop and plot only filtered data

5 vues (au cours des 30 derniers jours)
Megan
Megan le 4 Nov 2019
I want to filter my acceleration values and plot them afterwards.
ay.data contains all my accelerations and I just want to plot those that are greater than 1.5 and less than -1.5.
The background is to filter that it is a curve and not just a swinging.
Thanks a lot!
I tried that:
quer = meas.ay.data;
n = size(quer);
i = zeros(n);
for x = 1:length(i)
if quer(x)> 4
disp(quer(x));
hold on;
plot(quer(x));
ii= quer(x);
end
end

Réponse acceptée

Bob Thompson
Bob Thompson le 4 Nov 2019
This can be done much more simply with logic indexing.
quer = meas.ay.data;
quer = quer(quer > 1.5 | quer < -1.5);
plot(quer)
Looking at your loop, I'm not entirely sure if this is what you're looking for, but that's mostly because I don't understand how the value of acceleration relates to the matrix position of > 4.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by