Something like this should work:
function [ x ] = generate1(N,m,A3)
f1 = 100;
f2 = 200;
T = 1./f1;
t = (0:(N*T/m):(N*T))'; %'
fs = m/(T*N);
cutoff = 150;
wn = randn(length(t),1); %zero mean variance 1
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*wn;
[b,a] = butter(4, cutoff/(fs/2));
x_filt = filtfilt(b,a,x);
figure; plot(t,x)
hold on
plot(t,x_filt)
%[pks,locs] = findpeaks(x);
%plot(x)
end
The call to the butter function constructs a 4th order butterworth lowpass filter with a cutoff frequency specified by the cutoff parameter above (In our example it is 150Hz). the "a" and "b" values are the filter coefficients, which are applied to the x vector with the filtfilt() command. the result "x_filt" is a filtered version of x which contains frequency components less than 150Hz.