How to make sinewives with array input, for-loop functions and operate array with others [matlab]?
I really don't like doing someone's homework so I'll drop the loops and make a few other modifications and leave it up to you figure it out.

I don't really understand why you filtered the input but I kept it in:

clc
clear all
close all
%%
Ts = .001;
N = 1000;
t = (0:999)*Ts;
%f = [2 10 15 20 30 40 50 60 80 90 100 150 200 300 400];
% f = make_an_array;
f=logspace(log10(2),log10(400),50);
%%                             
input=exp(1j*2*pi*f'*t);      
[b,a] = butter(4,.02,'High');
[b1,a1] = butter(2,0.12);
input = filter(b1,a1,input);
output = filter(b,a,input);
G=output./input;
figure(1)
semilogx(f,20*log10(max(abs(G'))))
xlabel('frequency in Hz')
ylabel('Gain dB')
%A = max(output);
grid on
%disp(A)