First your a and b seems to be mis-named; replace b with a and a with b. Where b is the numerator coefficients of the filter and a is the denominator coefficients. Also note that the filter command works like this y = filter(b,a,x)...
Now it's correct thanks.
In any case, your input signal frequencies are so low that they are killed by the filter and hence you see no output. Just increase their frequencies to see them at the output. Incidentally you can also decrease fc well below 0.3 to get a tighter highpass (a DC-notch) filter..
I put 0.0003 for fc and the graph looked like this:
looks like the filter are cutting nothing because the plot of the two separete waves with sum are here:
Then also your fc parameter is not (directly) controlling the −3 dB cutoff frequency of the high pass filter that you intend to obtain.
I need to cut off the 0.3 rad/sample. I get the right answer with FIR filters but with IIR... i don't get it.
fs = 1000;
a = [(1+r)/2 -(1+r)/2];
b= [1 -r];
n = 0:1/(fs):0.5;
n1 = 1024;
x1 = cos(0.1*fs*pi*n);
x2 = cos(0.3*fs*pi*n);
%aux = fft((x1+x2),n1);
%aux = aux(1:n1/2);
f = (0:n1/2-1)*(2/n1);
y = filter([0.5759 -0.5759],[1 -0.1518] , x1+x2);
ux = fft((y),n1);
ux = ux(1:n1/2);
%axis([0 100 -1.2 4]);
xlabel('Time index n');
i put like u told and i normalized the f axes but here the FFT:
The wave of lowest freq remains. Thank you alot but i give it up.