Filtered signal plot not showing up
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
CB
am 15 Okt. 2020
Bearbeitet: Star Strider
am 15 Okt. 2020
I'm attempting to filter a certain portion of data from an external file using a moving average for a hw problem, and having trouble figuring out exactly what is wrong. I have no errors when I run the code, but my second plot doesn't show up.
clear all
load raw_data.mat
n = 200;
filter(500:700) = signal(500:700);
for k = 500:(n-1)
mean_w_curr = (signal(k-2) + signal(k-1) + signal(k) + signal(k+1) + signal(k+2))/5
mean_wo_curr = (signal(k-2) + signal(k-1) + signal(k+1) + signal(k+2))/4
if abs(mean_w_curr(k) - mean_wo_curr(k)) > .001
filter(k) = mean_wo_curr(k)
else
filter(k) = signal(k)
end
end
plot(500:700, signal(500:700),'r')
hold on
plot(filter(k),'b')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 15 Okt. 2020
Bearbeitet: Star Strider
am 15 Okt. 2020
It’s necessary for you to understand the problem with your indexing.
This:
n = 200;
k = 500:(n-1)
produces:
k =
1×0 empty double row vector
Since this is homework, I’m porviding you with this link to the documentation on the colon operator to understand the reaons this is not working.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!