Low Pass Filter, plotting a graph

In summary, your code produces three plots that simulate something. It looks as if it does so correctly. It would be nice if there was a way to automate that.
  • #1
Arman777
Insights Author
Gold Member
2,168
193
Homework Statement
Solving Diff Eqn
Relevant Equations
$$dV_{out}/dt = (V_{in} - V_{out}) / RC$$

$$V_{in}(t) = \begin{cases} 1 & \text{if floor(2t) is even} \\ -1 & \text{if floor(2t) is odd } \end{cases}$$
I wrote this code, but I am not sure its ture or not

Python:
from numpy import arange
from math import floor
from pylab import plot, show

Vout = 0 #inital condition
t_i = 0 #initial time
t_f = 10 #final time
N = 100000
h = (t_f - t_i) / N

RC_values = [0.01, 0.1, 1]

def f(Vout, t):
    if floor(2 * t) % 2 == 0:
        return (1 - Vout) / RC
    else:
        return (-1 - Vout) / RC
    

t_points = arange(t_i, t_f, h)
Vout_points = []

for RC in RC_values:
    for t in t_points:
        Vout_points.append(Vout)
        k1 = h * f(Vout, t)
        k2 = h * f(Vout + 0.5 * k1, t + 0.5 * h)
        k3 = h * f(Vout + 0.5 * k2, t + 0.5 * h)
        k4 = h * f(Vout + k3, t + h)
        Vout += 1/6 * (k1 + 2 * k2 + 2 * k3 + k4)
    plot(t_points, Vout_points, "go")
    Vout_points = []
    show()
 
Physics news on Phys.org
  • #2
What does 'ture' mean ?
Arman777 said:
its ture or not

Your code runs just fine :

1570141640289.png


This is on W10 with IDLE:
1570141697936.png
 
  • #3
BvU said:
What does 'ture' mean ?
Sorry I mean true. Well it runs fine but there could be mistakes in those plots .. Maybe I should have get another plot..Idk
 
  • #4
When is code 'true' ? Your script produces three plots that simulate something. It looks as if it does so correctly.

So for you , the thing to do is try and grasp the subject matter -- as opposed to polishing up the simulation :wink:

Maybe even do (on paper) a calculation of what you expect to see :biggrin:
 
  • #5
BvU said:
When is code 'true' ? Your script produces three plots that simulate something. It looks as if it does so correctly.

So for you , the thing to do is try and grasp the subject matter -- as opposed to polishing up the simulation :wink:

Maybe even do (on paper) a calculation of what you expect to see :biggrin:
thats kind of sad
 
  • #6
Why ?
 
  • #7
BvU said:
Why ?
I guess I undederstand the idea, I created some other simulations and they work well.. Its hard to do it on the paper..
 

FAQ: Low Pass Filter, plotting a graph

What is a Low Pass Filter?

A Low Pass Filter is an electronic circuit that allows low frequency signals to pass through while blocking high frequency signals. It is commonly used to remove noise or unwanted signals from a signal.

How does a Low Pass Filter work?

A Low Pass Filter works by using a combination of resistors, capacitors, and inductors to create a frequency-dependent voltage divider. This means that the output signal will have a different amplitude for different frequencies, effectively filtering out high frequency signals.

What is the purpose of plotting a graph for a Low Pass Filter?

Plotting a graph for a Low Pass Filter allows us to visualize the frequency response of the filter. This can help us understand how the filter affects the input signal, and also allows us to adjust the filter's parameters for different applications.

How do you plot a graph for a Low Pass Filter?

To plot a graph for a Low Pass Filter, you will need to know the filter's transfer function, which relates the input and output signals. You can then use a graphing software or hand-draw the graph by plugging in different frequencies into the transfer function and plotting the corresponding output values.

What are the applications of a Low Pass Filter?

A Low Pass Filter has various applications, including audio processing, signal conditioning, and data filtering. It is also commonly used in communication systems to remove noise and distortions from signals.

Similar threads

Replies
4
Views
1K
Replies
9
Views
3K
Replies
16
Views
1K
Replies
6
Views
1K
Replies
36
Views
4K
Replies
7
Views
2K
Replies
8
Views
3K
Replies
3
Views
2K
Back
Top