Question

3. (40 Pts.) Write a script which takes the frequency, amplitude and type (sinusoidal, square or triangular) of a function as input from user and plots the function y(t) at output. Hint: In MATLAB, you can generate a sinusoidal function by using sin, a square function by using square and a triangular function by using sawtooth functions. User-inputs Select any frequency within the interval FE lkHz, 100 kHz , select the amplitude of the signal VM and define the time vector t in the interval tE 0 0F with an increment of 0.001/F and type of the signal such as sin, square and triangular. (5 pts.) Draw a flowchart and explain your problem solving strategy. (12 Pts.) Take values of frequency, amplitude, and type from the user. (4 Pts.) Define vector t. (10 Pts.) Use a switch-case condition for different types of desired output function (different cases.) Within each case, calculate the output vector y. You may use either a loop or vector operation in this stage. a. b. c. d. e. (9 Pts.) Plot your output vector y versus time vector t. Put labels, title and legend to your figure.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

f=input('Enter frequency: ');
a=input('Enter amplitude: ');
type= input('Enter type: ','s');
F=f*1000;
t=0:.0001/F:10/F;
switch type
    case 'sin'
        y=a*sin(2*pi*F*t);
        plot(t,y)
        xlabel('t')
        ylabel('y')
        title(['y = (',num2str(a),')sin(2*pi*',num2str(F),')'])
        legend('sin wave')
    case 'triangle'
        y=a*sawtooth(2*pi*F*t);
        plot(t,y)
        xlabel('t')
        ylabel('y')
        title(['y = (',num2str(a),')sawtooth(2*pi*',num2str(F),')'])
        legend('triangle wave')
    case 'square'
        y=a*square(2*pi*F*t);
        plot(t,y)
        xlabel('t')
        ylabel('y')
        title(['y = (',num2str(a),')square(2*pi*',num2str(F),')'])
        legend('square wave')
end


Figure 1 Command Window File Edit View Insert Tools Desktop Window Help >>plot3Types Enter frequency: 4 Enter amplitude: 3 Enter type square y E (3)square(2 pi4000) fx >> square wave 0 -1 -2 -3 0.5 2.5 x 10-3 1.5

Add a comment
Know the answer?
Add Answer to:
3. (40 Pts.) Write a script which takes the frequency, amplitude and type (sinusoidal, square or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program which produces a constant-amplitude square wave with a frequency of 440Hz (440 cy...

    Write a program which produces a constant-amplitude square wave with a frequency of 440Hz (440 cycles per second). Using the init function, the output is configured to use signed 16-bit values for the signal, so a value of 0x8000 represents the “bottom” of the signal range, 0x0 represents the “middle” and 0x7FFF is the “top”. The output sample rate (the rate at which these 16-bit values come out) is 48kHz. This is all the info you need to put the...

  • PROBLEM 2 150 pts.] A signal is consist of three sine functions: the first one, ,...

    PROBLEM 2 150 pts.] A signal is consist of three sine functions: the first one, , has a wave frequency of 50 Hz, the second one, 2, has 100 Hz, and the last one, r3, has 200 Hz. However, each function has different amplitude: the amplitude of the first signal component x! is 10 cm, the amplitude of the second signal component xi s 5 cm; and the amplitude of the last signal component t3 is 1 cm. As a...

  • Name: ID NO: Section: 1. Assume that you have three sinusoidal signals and the parameters of...

    Name: ID NO: Section: 1. Assume that you have three sinusoidal signals and the parameters of each one of them is given below Amplitude is 3. cyclic frequency is 50Hz and phase shift is - Amplitude is 4, radian frequency is 40 and phase shift is Amplitude is 6, period is 0.05s, and phase shiftis- Write MATLAB code for the following Assume that the time interval is. Generate each signal Plot the above three signals in the same figure window...

  • Problem 31: (34 points) 1. (10 points) A pulse width modulated (PWM) signal fPwM(t) in Figure...

    Problem 31: (34 points) 1. (10 points) A pulse width modulated (PWM) signal fPwM(t) in Figure 2. The symbol D represents a duty cycle, a number between zero and one. Determine the compact trigonometric Fourier series coefficients (Co C,11 %) of the signal f(t). 2. (10 points) One use of PWM is to generate variable DC voltages. While the PWM signal is not DC, you should be able to see from your results in part 1 that it hss a...

  • Consider the plant sDs2) 1) What is the plant's type? 2) Let C(s) - K (a...

    Consider the plant sDs2) 1) What is the plant's type? 2) Let C(s) - K (a proportional controller). Find the closed-loop transfer function from reference to output using unity feedback. ) Choose different gains for K within the range 1 to 100. Plot the unit step response for the different gains. What happens with the transient response of the closed-loop as K increases? 4) For K 20 find the maximum value attained by the output y(t) and the settling time...

  • This is taken from Section 4.6, "Amplitude Modulation and the Continuous-Time Fourier Transform," in the course...

    This is taken from Section 4.6, "Amplitude Modulation and the Continuous-Time Fourier Transform," in the course text Computer Explorations in signals and systems by Buck, Daniel, Singer, 2nd Edition. I need the answers for the basic and intermediate questions. 4.6 Amplitude Modulation and the Continuous-Time Fouriei Transform This exercise will explore amplitude modulation of Morse code messages. A simple ampli tude modulation system can be described by x(t) = m(t) cos(Crfot), (4.13) where m(t) is called the message waveform and...

  • 1. Write an equation that describes voltage supplied by a wall outlet. (f = 60 Hz,...

    1. Write an equation that describes voltage supplied by a wall outlet. (f = 60 Hz, Vrms = 120 V) 2. What is the instantaneous voltage of a sine wave at half of a period? Describe Alternating Current (AC). Explain how resistors, capacitors, and inductors behave in an AC circuit. WRITEUP REQUIREMENTS Informal: Questions - 6 pts, Data Tables - 3 pts, Survey Questions from Syllabus - 1 pt INTRODUCTION V Up to this point, we have been using supply...

  • 5 pts D Question 1 A system has the following impulse response: .2 Sample number, n From the choices below, select the frequency response of this system. H (eju)-e(1.5 ) (2 sin( 1.5ώ) +...

    5 pts D Question 1 A system has the following impulse response: .2 Sample number, n From the choices below, select the frequency response of this system. H (eju)-e(1.5 ) (2 sin( 1.5ώ) + 4 sin(0.δώ)) H (ee) = e-j(1.5e-5) (cos( 1.5 ) +2 cos(0.54)) @ H (ee)-e-n1.si) (sin( 1.54) t. 2 sin(0.δώ)) (sin(l.50) +4sin(0.0) H (ee)-e-j(1.5i) (2 cos( 1.5ώ) + 4 cos(0.5a)) H (efo)-e-n1.5u) (cos( 1.50) + 2 cos(0.50)) https://rmitinstructure.comcoursesy 5 pts DQuestion 2 A system has the following...

  • t0 = 0; tf = 20; y0 = [10;60]; a = .8; b = .01; c...

    t0 = 0; tf = 20; y0 = [10;60]; a = .8; b = .01; c = .6; d = .1; [t,y] = ode45(@f,[t0,tf],y0,[],a,b,c,d); u1 = y(:,1); u2 = y(:,2); % y in output has 2 columns corresponding to u1 and u2 figure(1); subplot(2,1,1); plot(t,u1,'b-+'); ylabel('u1'); subplot(2,1,2); plot(t,u2,'ro-'); ylabel('u2'); figure(2) plot(u1,u2); axis square; xlabel('u_1'); ylabel('u_2'); % plot the phase plot %---------------------------------------------------------------------- function dydt = f(t,y,a,b,c,d) u1 = y(1); u2 = y(2); dydt = [ a*u1-b*u1*u2 ; -c*u2+d*u1*u2 ]; end Only...

  • write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle...

    write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT