How to make sinewives with array input and for-loop?

1 view (last 30 days)
if true
% code
function output = analog_filter1(input)
%
% Simulated analog filter used in Problem 1.3
%
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)
end
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'. And then, I got error message "Subscripted assignment dimension mismatch."

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!