It is often desirable to write matlab code without the inbuilt function. Here we show matlab code for plotting high pass filter without the inbuilt function. For low pass filter you can see How to plot low pass filter without inbuilt matlab function?.

The high pass filter has inductor at the output with inductance value 0.5mH and has a series source resistance of 50Ohm. The circuit is driven by an AC voltage source. Shown below is the circuit.

The matlab code for this high pass filter without the inbuilt matlab function is below.

The graph of Gain Vs Frequency from the above code is shown below.

The high pass filter has inductor at the output with inductance value 0.5mH and has a series source resistance of 50Ohm. The circuit is driven by an AC voltage source. Shown below is the circuit.

The matlab code for this high pass filter without the inbuilt matlab function is below.

clear clc; % HPF Rs = 50; j=sqrt(-1); L= 0.5*1e-3; for i=1:1e6 f(i) = i-1; fdB(i) = 10*log10(f(i)); Xl(i)= j*2*pi*f(i)*L; GdB(i) = 20*log10(abs(Xl(i)/(Rs + Xl(i)))); end fc = Rs/2*pi*L; fcdB = 10*log10(fc); figure plot(fdB,GdB) xlabel('Frequency') ylabel('Gain')

The graph of Gain Vs Frequency from the above code is shown below.

## No Comment to " How to plot high pass filter without inbuilt matlab function? "