Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2. y = 0.5 * t; 3. plot( t , y ); 4. xlabel ('Time Index t (sec.)'); 5. ylabel ('Amplitude'); 6. title ('Ramp Signal Sequence');
2. y = square ( 2 * pi * 50 * t);
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
Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010
S.No 1. fs = 10000;
MATLAB Code
2. t = 0 : 1/fs : 1.5;
5. xlabel ('Time Index t (sec.)'); ylabel ('Amplitude'); 6. title ('Sawtooth Wave Signal Sequence');
Explanation Set the sampling frequency fs as 10000. Generate a vector of 15001 samples for t with a value between 0 & 1.5 with an increment of 0.0001 Generate a Saw Tooth wave of frequency 100 Hz, by calling the MATLAB built-in function sawtooth. Plot the graph. Adjust the X and Y coordinates to view a few cycles of the Saw Tooth wave. Label the X and Y axes
Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010
3. x = sawtooth (2 * pi * 50 * t , 0.5);
5. xlabel ('Time Index t (sec.)'); ylabel ('Amplitude'); 6. title ('Triangular Wave Signal Sequence');
Explanation Set the sampling frequency fs as 10000. Generate a vector of 15001 samples for t with a value between 0 & 1.5 with an increment of 0.0001 Generate a Triangular wave of frequency 50 Hz, by calling the MATLAB built-in function sawtooth with 0.5 as the duty cycle parameter. Plot the graph. Adjust the X and Y coordinates to view a few cycles of the triangular wave. Label the X and Y axes
Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010
S.No 1. N=20;
MATLAB Code
2. t = -N : .0001 : N;
6. grid;
7. xlabel ('Time Index t (sec.)'); ylabel ('Amplitude'); 8. title ('Sinusoidal Signal of Frequency 50 Hz and Desired Phase');
Explanation Set a limit 20 for X-axis coordinate time. Generate a vector of 400001 samples for t with a value between -20 & 20 with a step size of 0.0001. The Xaxis range is from -20 to +20. Input the desired Phase Angle for the variable called theta Generate a Sine Wave of frequency 50 Hz and desired phase angle theta, by calling the MATLAB built-in function sin. Plot the graph. Adjust the X and Y coordinates to view a few cycles of the Sine wave. Insert horizontal and vertical grid in the graph for easy measurement of parameters. Label the X and Y axes
2. y = sinc(t);
3. plot( t , y ); 4. xlabel ('Time Index t (sec.)'); ylabel ('Amplitude'); 5. title ('Sinc Signal Sequence');
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. Label the X and Y axes Add an appropriate title to the graph
Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010
MATLAB Code
3. m1 = input ( ' Please input a NEGATIVE number for m1 '); 4. m2 = input ( ' Please input a POSITIVE number for m2 '); 5. m = [m1 : m2]; 6. x = zeros(1,m2-m1+1); 7. m0 = input ( ' Type 0 for Unit Impulse, negative/ positive no. for delayed/ advanced signal '); 8. x(m0-m1+1) = 1; 9. stem( m , x ); axis( [ m1 m2 -1.5 1.5 ] );
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. Adjust the X and Y coordinates to view a nice graph. Label the X and Y axes Add an appropriate title to the graph
10. xlabel ('Time Index m (sec.)'); ylabel ('Amplitude'); 11. title ('Unit Impulse Signal Sequence');
Text Book : Basic Simulation Lab with MATLAB Authors : Dr Bhanu Bhaskara, Siddhartha Bhaskara Publisher : Tata McGrawHill, 1st Edition, July 2010
2. k1 = input ( ' Please input a NEGATIVE number for k1 '); 3. k2 = input ( ' Please input a POSITIVE number for k2 '); 4. k0 = input ( ' Type 0 for normal Unit Step, a negative or positive no. for a shifted one '); 5. k = [k1 : k2]; 6. x = zeros(1,k2-k1+1); 7. x( k0-k1+1 : end ) = 1;
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. Plot the graph as stems. Adjust the X and Y coordinates to view a decent looking graph. Label the X and Y axes Add an appropriate title to the graph
8. stem( k , x ); axis ( [ k1 k2 -1.5 1.5 ] ); 9. xlabel ('Time Index k (sec.)'); ylabel ('Amplitude'); 10. title ('Unit Step Signal Sequence');