Matlab

March 21, 2018 | Author: arun_mukka | Category: Phase (Waves), Cartesian Coordinate System, Matlab, Amplitude, Sine


Comments



Description

Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010 Chapter 3: Generation of Signals and Sequences S.No MATLAB Code 1. t = 0 : 0.001 : 1; Explanation Generate a vector of 1001 samples for t with a value between 0 & 1 with an increment of 0.001 Generate a linear ramp with a slope of 0.5 Plot the graph Label the X-axis Label the Y-axis Add an appropriate title to the graph 2. y = 0.5 * t; 3. plot( t , y ); 4. xlabel ('Time Index t (sec.)'); 5. ylabel ('Amplitude'); 6. title ('Ramp Signal Sequence'); Table 3.1 : MATLAB code for Ramp Signal Generation S.No MATLAB Code 1. t = 0 : 0.0001 : 0.1; 2. y = square ( 2 * pi * 50 * t); 3. plot (t , y); axis ( [ 0 0.1 -2 2 ] ); 4. xlabel ('Time Index t (sec.)'); ylabel ('Amplitude'); 5. title ('Square Wave Signal Sequence'); Explanation Generate a vector of 10001 samples for t with a value between 0 & 0.1 with an increment of 0.0001 Generate a square wave of frequency 50 Hz, by calling the MATLAB inbuilt function ‘square’. Plot the graph. Adjust the X and Y coordinates to view a few cycles of the square wave. Label the X and Y axes Add an appropriate title to the graph Table 3.2 : MATLAB code for Square Wave Signal Generation 3 : MATLAB code for Saw Tooth Wave Generation . Plot the graph. Generate a vector of 15001 samples for t with a value between 0 & 1. July 2010 S.No 1.5 with an increment of 0. by calling the MATLAB built-in function ‘sawtooth’. axis ( [ 0 0. plot( t . 1st Edition. Adjust the X and Y coordinates to view a few cycles of the Saw Tooth wave. 6. Siddhartha Bhaskara Publisher : Tata McGrawHill. MATLAB Code 2. ylabel ('Amplitude'). t = 0 : 1/fs : 1. fs = 10000.05 -1 1 ] ). x = sawtooth (2 * pi * 100 * t). Explanation Set the sampling frequency fs as 10000. title ('Sawtooth Wave Signal Sequence').)'). 4.Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara. x ).5. Label the X and Y axes Add an appropriate title to the graph Table 3. 5.0001 Generate a Saw Tooth wave of frequency 100 Hz. 3. xlabel ('Time Index t (sec. 1 -1 1 ] ). title ('Triangular Wave Signal Sequence'). Explanation Set the sampling frequency fs as 10000.x). xlabel ('Time Index t (sec.Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara. ylabel ('Amplitude'). x = sawtooth (2 * pi * 50 * t . 6. Plot the graph.5 with an increment of 0.5 as the duty cycle parameter.)'). Generate a vector of 15001 samples for t with a value between 0 & 1. fs = 10000.5). 3. Siddhartha Bhaskara Publisher : Tata McGrawHill. Adjust the X and Y coordinates to view a few cycles of the triangular wave. 1st Edition. plot(t.5. axis ( [ 0 0. by calling the MATLAB built-in function ‘sawtooth’ with 0. 4. t = 0 : 1/fs : 1. 2. Label the X and Y axes Add an appropriate title to the graph Table 3.No MATLAB Code 1.0001 Generate a Triangular wave of frequency 50 Hz. 0. 5.4 : MATLAB Code for Triangular Wave Generation . July 2010 S. 6. x ). x = sin (2 * pi * 50 * t + theta).0001.)'). 2. 1st Edition. Siddhartha Bhaskara Publisher : Tata McGrawHill. plot( t . 5. Adjust the X and Y coordinates to view a few cycles of the Sine wave. grid. 4.No 1. plot( t . 3. ylabel ('Amplitude'). July 2010 S.Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara. title ('Sinusoidal Signal of Frequency 50 Hz and Desired Phase'). Explanation Generate a vector of 100 linearly spaced samples for t with a value between -5 & 5 Call the built-in 'Sinc' function to generate the Sinc signal of 100 samples Plot the graph. 5). Generate a vector of 400001 samples for t with a value between -20 & 20 with a step size of 0. 7. title ('Sinc Signal Sequence'). N=20. xlabel ('Time Index t (sec. 4. 3. Plot the graph. Label the X and Y axes Add an appropriate title to the graph Table 3. y ). t = -N : . theta = input('The phase angle is '). Input the desired Phase Angle for the variable called ‘theta’ Generate a Sine Wave of frequency 50 Hz and desired phase angle ‘theta’. The Xaxis range is from -20 to +20.5 : MATLAB Code for Sine Wave Signal Generation S. by calling the MATLAB built-in function ‘sin’.04 -1 1] ). Insert horizontal and vertical grid in the graph for easy measurement of parameters.No MATLAB Code 1. Explanation Set a limit 20 for X-axis coordinate ‘time’.04 . MATLAB Code 2. ylabel ('Amplitude'). xlabel ('Time Index t (sec. axis( [-.0001 : N.)'). 5. 8. Label the X and Y axes Add an appropriate title to the graph Table 3. y = sinc(t). t = linspace(-5 .6 : MATLAB Code for Sinc Signal Generation . m1 = input ( ' Please input a NEGATIVE number for “m1” '). Label the X and Y axes Add an appropriate title to the graph 10. 8. MATLAB Code 3. 6. 2. axis( [ m1 m2 -1. 7. Explanation Clear Command Window for a clean view Clear all the previously defined variables Set a limit for negative X-axis Set a limit for positive X-axis Define the range for X-axis Create a row vector of zeros Define the place of the single unit impulse on the X-axis Set the amplitude of the unit impulse as ‘1’ at the defined place Plot the graph as stems. m = [m1 : m2]. m0 = input ( ' Type 0 for Unit Impulse. x ).5 1. 5.)'). Siddhartha Bhaskara Publisher : Tata McGrawHill. 9. Adjust the X and Y coordinates to view a nice graph.5 ] ). 11. m2 = input ( ' Please input a POSITIVE number for “m2” '). x(m0-m1+1) = 1. stem( m .Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara. xlabel ('Time Index m (sec. 1st Edition. July 2010 S. clear all. for delayed/ advanced signal '). clc. negative/ positive no. title ('Unit Impulse Signal Sequence'). Table 3. ylabel ('Amplitude').m2-m1+1). 4.7 : MATLAB Code for Unit Impulse Signal Generation . x = zeros(1.No 1. clear all. title ('Unit Step Signal Sequence'). k2 = input ( ' Please input a POSITIVE number for “k2” '). k = [k1 : k2]. Table 3. for a shifted one ').)'). k0 = input ( ' Type 0 for normal Unit Step.5 ] ). xlabel ('Time Index k (sec. 9. 7.8 : MATLAB Code for Unit Step Signal Generation .Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara.5 1. 4. stem( k . Siddhartha Bhaskara Publisher : Tata McGrawHill. x( k0-k1+1 : end ) = 1. July 2010 S. Label the X and Y axes Add an appropriate title to the graph 8. Plot the graph as stems. Adjust the X and Y coordinates to view a decent looking graph. 3. 6. clc. x = zeros(1. 2.No MATLAB Code 1. 1st Edition. a negative or positive no. 10. axis ( [ k1 k2 -1. 5. ylabel ('Amplitude'). k1 = input ( ' Please input a NEGATIVE number for “k1” ').k2-k1+1). x ). Explanation Clear Command Window and all the previously defined variables for a clean view Set a limit for negative X-axis Set a limit for positive X-axis Decide on the type of Unit Step desired and accordingly feed an input Define the range for X-axis Create a row vector of zeros Set the amplitude of the unit step as ‘1’ from the place of starting until end.
Copyright © 2024 DOKUMEN.SITE Inc.