Difference between revisions of "ECE 280/Spring 2024/HW 07"

From PrattWiki
Jump to navigation Jump to search
(Notes)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
For some parts of Homework 7, in addition to uploading the PDF of your work, you will be coding your answer and uploading it to Gradescope.  All you need to do is write code that replicates your formula - generally, this will go after the word <code>return</code> in a function that is either called <code>X_letter</code> or <code>x_letter</code> depending on whether you are finding a Fourier transform or an inverse Fourier transform, respectively.  The code for 4.21(b) and 4.22(c) is already done; the handwritten work is on Canvas.
+
For some parts of Homework 7, in addition to uploading the PDF of your work, you will be coding your answer and uploading it to Gradescope.  All you need to do is write code that replicates your formula - generally, this will go after the word <code>return</code> in a function that is either called <code>X_letter</code> or <code>x_letter</code> depending on whether you are finding a Fourier transform or an inverse Fourier transform, respectively.  The code for 4.21(b, f) and 4.22(c, e) is already done; the handwritten work is on Canvas.
  
 
== Notes ==
 
== Notes ==
Line 10: Line 10:
 
def x_a(t):
 
def x_a(t):
 
     u = lambda t: (t>0)*1.0
 
     u = lambda t: (t>0)*1.0
     return 0</syntaxhighlight>
+
     return 0*t</syntaxhighlight>
 
* If your function has multiple symbolic parameters, the example file for it will have that as well.  For instance, in 4.21(a), your answer will have the exponent $$a$$ and sinusoidal frequency $$\omega_0$$; the example function is:<syntaxhighlight lang=python>
 
* If your function has multiple symbolic parameters, the example file for it will have that as well.  For instance, in 4.21(a), your answer will have the exponent $$a$$ and sinusoidal frequency $$\omega_0$$; the example function is:<syntaxhighlight lang=python>
 
def X_a(w, a, w0):
 
def X_a(w, a, w0):
     return 0</syntaxhighlight>
+
     return 0*w</syntaxhighlight>
 
* Do not use square brackets in place of parentheses; <code>[0]+[1]</code> yields a list <code>[0, 1]</code> whereas <code>(0)+(1)</code> yields 1.
 
* Do not use square brackets in place of parentheses; <code>[0]+[1]</code> yields a list <code>[0, 1]</code> whereas <code>(0)+(1)</code> yields 1.
 
* $$\frac{1}{j\omega}$$ needs to be coded as <code>1/(1j*w)</code> or <code>1/1j/w</code>, not <code>1/1j*w</code> (that would be $$\frac{w}{j}$$)
 
* $$\frac{1}{j\omega}$$ needs to be coded as <code>1/(1j*w)</code> or <code>1/1j/w</code>, not <code>1/1j*w</code> (that would be $$\frac{w}{j}$$)

Latest revision as of 02:09, 18 March 2024

For some parts of Homework 7, in addition to uploading the PDF of your work, you will be coding your answer and uploading it to Gradescope. All you need to do is write code that replicates your formula - generally, this will go after the word return in a function that is either called X_letter or x_letter depending on whether you are finding a Fourier transform or an inverse Fourier transform, respectively. The code for 4.21(b, f) and 4.22(c, e) is already done; the handwritten work is on Canvas.

Notes

  • $$\pi$$ is written as np.pi
  • $$a^b$$ is written as a**b
  • cos(t) is written as np.cos(t)
  • sin(t) is written as np.sin(t)
  • $$e^{t}$$ is written as np.exp(t)
  • If you need to define a subfunction, define it in the context of your main function. For instance, in 4.22(a), your answer needs the unit step function. As a result, the example file has it within the x function:
    def x_a(t):
        u = lambda t: (t>0)*1.0
        return 0*t
    
  • If your function has multiple symbolic parameters, the example file for it will have that as well. For instance, in 4.21(a), your answer will have the exponent $$a$$ and sinusoidal frequency $$\omega_0$$; the example function is:
    def X_a(w, a, w0):
        return 0*w
    
  • Do not use square brackets in place of parentheses; [0]+[1] yields a list [0, 1] whereas (0)+(1) yields 1.
  • $$\frac{1}{j\omega}$$ needs to be coded as 1/(1j*w) or 1/1j/w, not 1/1j*w (that would be $$\frac{w}{j}$$)