Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help generating this in Matlab. 1) generate_square_wave Write a function called generate_square_wave that generates a square wave. The desired amplitude, number of periods, and
Need help generating this in Matlab.
1) generate_square_wave Write a function called generate_square_wave that generates a square wave. The desired amplitude, number of periods, and number of samples per period (a.k.a. # of data points in each period) are passed into the function. The function returns a row vector containing the y values of a square wave. For example, if the following code was executed: y = generate_square_wave(3, 10, 100); t = 0: length(y)-1; plot(t,y, '.-'); the following graph should be displayed: 3.5 3 - - - - - - LI - 2.5 2 1.5 1 0.5 0 -0.5 0 200 400 600 800 1000 2) generate_triangle_wave Write generate_triangle_wave(), which has the same input and output parameters as generate_square_wave(). If the above code instead called generate_triangle_wave(), the following plot should result: 3.5 3 2.5 2 1.5 1 0.5 0 -0.5 0 200 400 600 800 1000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started