Thanks to previous question, I got some clues to resolve this one. But, I still get some problems here.
Ts = .001; N = 1000; t = (0:999)*Ts; make_an_array = [2 10 15 20 30 40 50 60 80 90 100 150 200 300 400]; f = make_an_array; for i=1:length(t) input(i)=sin(2*pi*f(1)*t(i)); end [b,a] = butter(4,.02,'High'); [b1,a1] = butter(2,0.12); input = filter(b1,a1,input); output = filter(b,a,input); for i=1:length(output) G(i) = 20*log(output/f(1)); end semilogx(f,G,'x') xlabel('frequency in Hz') ylabel('Gain dB') A = max(output); grid on disp(A)
This is a brief explaination about what I am trying to find:
1. Amplitude of the output with max operator (variable A) 2. Sine wives using input frequencies in an array (variable f) and use a for-loop (input (i)) 3. Plot the 20 log of the output values against the frequency array using the semilogx. 4. I dont know about how to 'store the maximum values of the flter’s output in an array for plotting'. 5. And then, I got error message "Subscripted assignment dimension mismatch." 6. Part of codes is already on the book: [b,a] = butter(4,.02,'High'); [b1,a1] = butter(2,0.12); input = filter(b1,a1,input); output = filter(b,a,input);
I think I got wrong on trying to find the value of G, how to operate value with array function (like in input(i) and G(i)).