Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help. do it using matlab. Thanks!! this is what i write so far : T=1; i=1001; n=[1 3 10 100]; function [t,V]=sqwave(n,T,i) for l=0:1:i

please help. do it using matlab. Thanks!!image text in transcribedimage text in transcribed

this is what i write so far :

T=1; i=1001;

n=[1 3 10 100];

function [t,V]=sqwave(n,T,i) for l=0:1:i t(l+1)=(T/i)*l; end

for l=1:1:length(t) V(l)=0; for i=1:1:n V(l)=V(l)+((4/pi)*sin((2*pi*t(l))/T)); end end end

title('V vs. t plot')

xlabel('t')

ylabel('V')

legend('Actual sq wave','Fourier:1 term','Fourier:3 term','Fourier:10 term','Fourier:100 term')

Mathematician Joseph Fourier is credited with the theorem that any periodic waveform may be expressed as a summation of pure sines and cosines. For example, the square wave of Figure P2.16a can be written as a sum of sines k odd Figure P2.16b shows the first three terms of the series and their summation. a) Write a MATLAB script that utilizes the self-written function sqwave (n, T,i) which takes the following arguments: n the number of terms of the Fourier series the period of the square wave in seconds. i the number samples per period. The function should return two arrays, t and V, each containing i elements, where tan array of i time points. V = an array of i computed values of the nth-degree approximated square wave b) Run your sqwave (n,T,i) function and plot the results for the following arguments: T = 1 millisec, i-1001, n = 1, 3, 10, 100 c For n-100, print out a table of (t, V) at every 20 time points in a text file. -1 ms st term Sum of 1st, 2nd and 3rd terms 2nd term 3rd ternm Figure P2.16. (a) Square wave. (b) Three term in a Fourier series of a square wave Mathematician Joseph Fourier is credited with the theorem that any periodic waveform may be expressed as a summation of pure sines and cosines. For example, the square wave of Figure P2.16a can be written as a sum of sines k odd Figure P2.16b shows the first three terms of the series and their summation. a) Write a MATLAB script that utilizes the self-written function sqwave (n, T,i) which takes the following arguments: n the number of terms of the Fourier series the period of the square wave in seconds. i the number samples per period. The function should return two arrays, t and V, each containing i elements, where tan array of i time points. V = an array of i computed values of the nth-degree approximated square wave b) Run your sqwave (n,T,i) function and plot the results for the following arguments: T = 1 millisec, i-1001, n = 1, 3, 10, 100 c For n-100, print out a table of (t, V) at every 20 time points in a text file. -1 ms st term Sum of 1st, 2nd and 3rd terms 2nd term 3rd ternm Figure P2.16. (a) Square wave. (b) Three term in a Fourier series of a square wave

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions