Cody

Solution 2237324

Submitted on 26 Apr 2020 by William
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
T = 2; Ts = 0.01; t = 0:Ts:T-Ts; A = 2; f = zeros(size(t)); f(t < (T/2)) = A; f((t>=(T/2)) & (t<T)) = -A; N = 10; coeffs_correct =[0 0.04 0 0.04 0 0.04 0 0.04 0 0.04 0;0 2.546 0 0.848 0 0.508 0 0.362 0 0.281 0]; assert(any(any(abs(fourier_series(f,N,T,Ts,'real')-coeffs_correct)<1e-3)))

2   Pass
T = 1; Ts = 0.01; t = 0:Ts:T-Ts; N = 10; f = sin(2*pi*2*t) - 3*sin(2*pi*3*t) + 2*cos(2*pi*4*t); coeffs_correct = [0 0 2 0 0-3i 0 0+1i 0 0 0 0 0 0 0 0-1i 0 0+3i 0 2 0 0]; assert(any(any(abs(fourier_series(f,N,T,Ts,'complex')-coeffs_correct)<1e-3)))

Suggested Problems