Fs = 512;  % Sampling Frequency
Fnotch = 50;  % Notch Frequency
Q      = 3;   % Q-factor
Apass  = 1;   % Bandwidth Attenuation
BW = Fnotch/Q;
[b  a] = iirnotch(Fnotch/(Fs/2),  BW/(Fs/2),  Apass);
Hd     = dfilt.df2(b,  a);

data = [-65.2552375331956 -87.6069637061080 -93.6854529359693 -79.1531425199174 ...
    -48.2738270876365 -11.3455296547654 18.4125110652110 30.3039244614931 ...
    21.5992918264975 -3.00973738565949 -32.5759811153733 -54.2637946296843 ...
    -56.9637061079965 -38.5954558866922 -3.52611389790499 37.0905871938625 ...
    70.7878430215403 87.0905871938625 82.8120389495426 62.3487754499853 ...
    35.6742401888463 13.5143110061965 5.38506934198879 14.5028031867808 ...
    36.2791383889053 62.4372971377988 83.5939805252287 91.2363529064621 ...
    83.5054588374152 62.2159929182650 34.2283859545589 8.08498082030097 ...
    -8.83741516671585 -11.8028917084686 -1.69666568309236 16.1699616406019 ...
    34.8332841546179 45.9575095898495 43.0805547359103 25.4647388610210 ...
    -3.71791088816760 -36.2201239303629 -62.4668043670699 -73.7238123340218 ...
    -67.6158158748894 -46.2378282679256 -18.9288875774565 3.45234582472706 ...
    10.6816169961641 -0.885216878135143 -27.6630274417232 -60.0767187961050 ...
    -85.3349070522278 -93.0658011212747 -79.9055768663323 -49.3360873413986 ...
    -12.4963115963411 17.7781056358808 31.1301268810859 24.5352611389791 ...
    2.34582472705813 -24.5500147536146 -44.3641192092063 -47.8312186485689 ...
    -32.1186190616701 -2.93596931248156 30.2744172322219 56.5358512835645 ...
    67.9108881676011 62.7028622012393 44.7034523458247 21.8648568899380 ...
    3.18678076128652 -3.67365004426084 4.69164945411626 26.3794629684273 ...
    54.5146060784892 80.8350545883742 96.5181469460018 96.0902921215698 ...
    78.9465919150192 49.9704927707288 17.0404249041015 -8.98495131307170 ...
    -20.2714665092948 -14.1782236647979 5.93095308350546 31.2924166420773 ...
    50.3540867512541 53.9834759516081 37.6807317792859 5.26704042490410 ...
    -33.6382413691354 -65.2109766892889 -79.9793449395102 -72.9861316022425 ...
    -49.2475656535851 -18.4862791383889 5.79817055178519 12.7471230451461 ...
    -0.752434346414872 -30.6137503688404 -66.4355267040425 -94.9247565653585 ...
    -105.222779580997 -93.3018589554441 -64.6503393331366 -27.9580997344349 ...
    3.90970787843022 22.1304219533786 22.7058129241664 9.28002360578342 ...
    -10.9619356742402 -28.1498967246976 -34.7152552375332 -26.5122455001475 ...
     -4.66214222484509 24.4172322218944 53.0539982295663 72.6910593095308 ...
    77.7958099734435 68.3387429920331 47.5656535851284 23.4730008852169 ...
    6.25553260548834 3.08350545883742 16.3765122455001 42.5641782236648 ...
    72.5877840070817 95.4116258483329 101.740926526999 87.7102390085571 ...
    57.3768073177929 20.2272056653880 -10.6373561522573 -24.2549424609029 ...
    -16.9666568309236 6.74240188846267 36.2348775449985 58.1144880495721 ...
    61.7143700206551 43.8920035408675 9.04396577161405 -30.7612865151962 ...
    -63.0126881085866 -77.4122159929183 -71.0829153142520 -48.5688993803482 ...
    -20.1386839775745 3.05399822956624 11.2422543523163 1.53437592210091 ...
    -21.8205960460313 -51.0179994098554 -75.4057244024786 -86.2053703157274 ...
    -80.0383593980525 -58.9997049277073 -29.3154322809088 0.103275302449100 ...
    20.0501622897610 25.6122750073768 15.7421068161700 -4.10150486869283 ...
    -26.1286515196223 -40.4986721746828 -39.7609914429035 -21.6435526704043 ...
    -50.2213042195338 -11.4488049572145 21.0976689288876 35.8660371791089];
data1 = filter(b, a, data);
x = 1:length(data);
plot(x, data, x, data1);
legend('原始信号', '滤波后信号');

image