<h3><center>Be a productive human being! <hr /> <h1>What is MATLAB? <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png" alt="logo.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png 2x" /> <blockquote> <p dir="auto">MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment. A proprietary programming language developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of¬ algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, C#, Java, Fortran and Python. ---Wikipedia <blockquote> <p dir="auto">MATLAB is specifically designed for engineers and scientists. It possesses a matrix-based language that allows natural act or instance of representing a computational mathematics. <blockquote> <p dir="auto">MATLAB combines a desktop environment tuned for iterative analysis and design processes with a programming language that expresses matrix and array mathematics directly. <p dir="auto">We can say that MATLAB is specifically designed to provide multi-paradigm numerical computing environment for engineers and scientists. Since this type of computing environment possesses a matrix-based language therefore it allows natural instances in representing a computational mathematics. <hr /> <h1>A glimpse in the Capabilities of MATLAB <h3>Click the words with the font color of green to be directed to some posts I’ve already exposed about MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/unleashing-the-capabilites-of-matlab-1" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 001) Unleashing the Capabilities of MATLAB #1 <h6>In the post above, you’ll be able to understand the big difference between a continuous-time signal and a discrete-time signal using MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/ulog-tutorial-002-how-to-install-activate-and-run-matlab" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 002): How to Install, Activate, and Run MATLAB 😲 <h6>In the post above, you’ll be able to know how to <strong>INSTALL, <strong>ACTIVATE, and <strong>RUN MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/unleashing-the-capabilities-of-matlab-2-basic-signal-operations-continuous-time-signal" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 003): Unleashing the Capabilities of MATLAB #2 (Basic Signal Operations: Continuous-Time Signal) <h6>In the post above, you’ll be able to know how to Apply the BASIC SIGNAL OPERATIONS in a CONTINUOUS-TIME SIGNAL using MATLAB. <hr /> <p dir="auto">These days I am exploring more of this amazing and interesting application and as I am learning, I kind of wanting to share it to you so here I am. So, without further ado, this time, we are going to learn about the <strong>Basic Signal Operations of <strong>Digital Processing Signals <hr /> <h1>What are the Basic Signal Operations of Digital Processing Signals? <ul> <li><p dir="auto"><strong>Time Shifting<br /> Time Shifting Operation is the result you get when you change the positioning of the signal without affecting its amplitude. It can either be delayed or advanced compared to the original signal. To change the positioning of a signal you just need to subtract the fundamental period from the time. <li><p dir="auto"><strong>Time Reversal<br /> Time Reversal Operation is basically the reflection or the reverse of the original signal. To reverse a signal, you just need to multiply time with negative one. <li><p dir="auto"><strong>Time Scaling<br /> Time Scaling Operation is the result when the time of the original signal is being multiplied by a time-variable or a scaling factor. The original signal can either be stretched or compressed. <hr /> <p dir="auto">To understand more about the basic signal operations, let us construct codes that will show their graphs by using MATLAB. <hr /> <hr /> <h1>Things to consider in using MATLAB <ul> <li><p dir="auto">Put Two Percent-Signs (%%)<br /> Always put two percent-signs to create sections of the program. This is necessary when we are dealing with various elements and codes that are meant for different graphs or commands. This allows us to run the program separately from other sections. <li><p dir="auto">MATLAB is Sequential Type of Programming Platform<br /> This factor is very important to remember since the program may not be able to run if the inputted values are not in sequence. Therefore, there is a sequence that is in need to be followed. It is essential to first encode the values of every variables you are to represent before encoding a function or equation. <li><p dir="auto">Put Colon (:) to Create Matrix<br /> Put colon whenever you want to construct a matrix. Let us use time as an example. Time is an independent variable and since it has no ending, for us to establish limits we need to construct a matrix. So, how to construct a matrix? Just follow <strong>start:interval:end. <li><p dir="auto">Variables Represented are Limited<br /> The only variables that can be represented in a MATLAB are letters, numbers, and dollar sign. <li><p dir="auto">Parenthesis is in Need to Analyze the Program<br /> When you are about to call or analyze the program you made, you need to enclose the Variable you represent with parenthesis. <li><p dir="auto">plot(<em>variable represented)<br /> That is what you need to encode when you are going to analyze a program for Continuous-Time Signal. <li><p dir="auto">stem(<em>variable represented)<br /> That is what you need to encode when you are going to analyze a program for Discrete-Time Signal. <li><p dir="auto">subplot(y,x,n)<br /> To subplot programs, you need to consider the number of figures that are to be represented in y-axis, x-axis and the number of variables to be represented. <strong>y is for the number of figures that are to be represented in y-axis; <strong>x is for the number of figures that are to be represented in x-axis; and <strong>n is for the number of variables to be represented. <hr /> <h1>Sneak Peak for This Topic: <ul> <li>Our original signal is the Continuous-Time Signal and we’ll have sinewave as an example since it is common and easy to understand. Sinewave is equal to <pre><code>A*sin(2*pi*f*t); <ul> <li>This time we are going to have Discrete-Time Signal so, we are to convert it simply by replacing time with the product of number of samples and the sampling time. It’ll look like this: <pre><code>A*sin(2*pi*f*n*ts); <ul> <li>Since we have too many functions and sections to perform so you’ll also be learning how to save a function and how to call it. <h6>This function will be used throughout the entire program <ul> <li>When plotting a called function you must use <pre><code>plot(*time*,*variable*); ##for Continuous-Time Signal <pre><code>stem(*time*,*variable*); ##for Discrete-Time Signal <ul> <li><p dir="auto">We use xlabel('<em>Your preferred name') to label every section. <li><p dir="auto">Our fundamental periods are denoted with t0. <li><p dir="auto">Our scaling factor is denoted with a. <li><p dir="auto">We’ll be having eight sections in this program. <hr /> <hr /> <h1>Using MATLAB <hr /> <ul> <li><p dir="auto">Open your MATLAB<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png" alt="intro.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png 2x" /> <li><p dir="auto">Go to the <strong>MATLAB Editor to start encoding the program<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png" alt="01.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png 2x" /> <h6>First, we are going to plot our Continuous-Time Signal. Then we are going to apply all the operations to Discrete-Time Signal and compare all their graphs. <hr /> <ul> <li>The whole program will begin by creating a function. So, in the editor, type the codes I encoded below <pre><code>function xt = sinewave(A,f,t) xt = A*sin(2*pi*f*t) end <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png" alt="02.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png 2x" /> <ul> <li><p dir="auto">Save it using <strong>”sinewave”<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png" alt="03.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png 2x" /> <li><p dir="auto">Open another Editor and let us start with our Original Signal <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png" alt="04.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png 2x" /> <hr /> <h6>Since I stated above that sinewave is what we are going to use as an example, so we’ll first create our first section. This section will be our original signal. <pre><code>%% Continuous <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need. But this time, since we are calling a function from the first editor then time will only be the value we need to be encoded first before encoding anything else in the program <pre><code>t = [0:.001:.06]; <h6>Now let us encode the equation of the first variable we are to represent. And you may be curious about its structure but that is what our equations will look like because once again, we are calling the function we made in the first editor. <pre><code>Y = sinewave(10,50,t); <h6>Since the goal is to represent “Y” we’ll follow the rules above. <pre><code>plot(t,Y); <h6>To recognize the section, let us label it. <pre><code>xlabel('Original Signal - Continuous') <h5>So, the first section is: <pre><code>%% Continuous t = [0:.001:.06]; Y = sinewave(10,50,t); plot(t,Y); xlabel('Original Signal - Continuous') <h6>Then press the <strong><em>"Run"icon to run the program. <h6>The graph below is the representation of the Continuous-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png" alt="05.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png 2x" /> <hr /> <h6>Since I stated above that we are to apply operations with Discrete-Time Signal so we’ll create our second section. <pre><code>%% Discrete <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <pre><code>n = (0:20); f = 50; fs = 10*f; ts = 1/fs; <h6>Now let us encode the equation of the second variable we are to represent. And you may be curious about its structure but that is what our equations will look like because once again, we are calling the function we made in the first editor. <pre><code>X = sinewave(10,50,n*ts); <h6>Since the goal is to represent “X” we’ll follow the rules above. <pre><code>stem(X); <h6>To recognize the section, let us label it. <pre><code>xlabel('Discrete'); <h5>So, the second section is: <pre><code>%% Discrete n = (0:20); f = 50 fs = 10*f ts = 1/fs X = sinewave(10,50,n*ts); stem(X) xlabel('Discrete'); <h6>Then press the <strong><em>"Run"icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png" alt="06.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Shifting Operations to show us the difference between ADVANCE and DELAY. These will serve as our third and fourth sections. Time Shifting results when we subtract periods (t0) from our time (t) <h6>Starting with ADVANCE, we are going to provide another section. <pre><code>%% Time Shifting: Advance <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to ADVANCE when the value of our (t0) is greater than zero. <pre><code>t0 = 2; <h6>Now let us encode the equation of the third variable we are to represent. <pre><code>X1 = sinewave(10,50,(n*ts)-t0); <h6>Since the goal is to represent “X1” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X1); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Shifting: Advance') <h5>So, the third section is: <pre><code>%% Time Shifting: Advance t0 = 2; X1 = sinewave(10,50,(n*ts)-t0); stem((n*ts)-t0,X1); xlabel('Time Shifting: Advance') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png" alt="07.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png 2x" /> <hr /> <h6>This time, we’ll be having the DELAY. We are going to provide another section. <pre><code>%% Time Shifting: Delay <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to DELAY when the value of our (t0) is less than zero. <pre><code>t0 = -2; <h6>Now let us encode the equation of the fourth variable we are to represent. <pre><code>X2 = sinewave(10,50,(n*ts)-t0); <h6>Since the goal is to represent “X2” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X2); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Shifting: Delay') <h5>So the fourth section is: <pre><code>%% Time Shifting: Delay t0 = -2; X2 = sinewave(10,50,(n*ts)-t0); stem((n*ts)-t0,X2); xlabel('Time Shifting: Delay') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png" alt="08.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Reversal Operations to show us the difference between the Reversal of ADVANCE and the Reversal of DELAY. Time Reversal results when multiplying negative one (-1) to our time (t) <h6>Starting with ADVANCE, we are going to provide another section. <pre><code>%% Time Reversal: Advance <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to ADVANCE when the value of our (t0) is greater than zero. <pre><code>t0 = 2; <h6>Now let us encode the equation of the fifth variable we are to represent. <pre><code>X3 = sinewave(10,50,(-1*n*ts)-t0); <h6>Since the goal is to represent “X3” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X3); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Reversal: Advance') <h5>So the fifth section is: <pre><code>%% Time Reversal: Advance t0 = 2; X3 = sinewave(10,50,(-1*n*ts)-t0); stem((n*ts)-t0,X3); xlabel('Time Reversal: Advance') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png" alt="09.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png 2x" /> <hr /> <h6>This time, we’ll be having the DELAY. We are going to provide another section. <pre><code>%% Time Reversal: Delay <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to DELAY when the value of our (t0) is less than zero. <pre><code>t0 = -2; <h6>Now let us encode the equation of the sixth variable we are to represent. <pre><code>X4 = sinewave(10,50,(-1*n*ts)-t0); <h6>Since the goal is to represent “X4” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X4); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Reversal: Delay') <h5>So the sixth section is: <pre><code>%% Time Reversal: Delay t0 = -2; X4 = sinewave(10,50,(-1*n*ts)-t0); stem((n*ts)-t0,X4); xlabel('Time Reversal: Delay') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png" alt="10.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Scaling Operations to show us the difference between EXPANDED and COMPRESSED version of the Original Signal. Time Scaling results when we multiply a scaling factor (a) to our time (t) <h6>Starting with EXPANDED; we are going to provide another section. <pre><code>%% Time-Scaling: Expanded <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is scaled to EXPAND when the value of our (a) is greater than zero but less than 1. <pre><code>a = .5; <h6>Now let us encode the equation of the seventh variable we are to represent. <pre><code>X5 = sinewave(10,50,a*(n*ts)); <h6>Since the goal is to represent “X5” we’ll follow the rules above. <pre><code>stem((n*ts),X5); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Scaling: Expanded') <h5>So the seventh section is: <pre><code>%% Time Scaling: Expanded a = .5; t = [0:.001:.06]; X5 = sinewave(10,50,a*(n*ts)); stem((n*ts),X5); xlabel('Time Scaling: Expanded') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png" alt="11.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png 2x" /> <hr /> <h6>This time, we’ll be having the COMPRESSED version of the original signal. We are going to provide another section. <pre><code>%% Time-Scaling: Compressed <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is scaled to COMPRESS; when the value of our (a) is greater than one. <pre><code>a = 2; <h6>Now let us encode the equation of the eighth variable we are to represent. <pre><code>X6= sinewave(10,50,a*n*ts); <h6>Since the goal is to represent “X6” we’ll follow the rules above. <pre><code>stem(n*ts,X6); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Scaling: Compressed') <h5>So the eighth section is: <pre><code>%% Time Scaling: Compressed a = 2; t = [0:.001:.06]; X6= sinewave(10,50,a*n*ts); stem(n*ts,X6); xlabel('Time Scaling: Compressed') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png" alt="12.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png 2x" /> <hr /> <h1>SUBPLOTTING <p dir="auto">This time, we’ll be comparing the graph from each other to see their difference and to prove the validity of the operations. We are going to have <strong>4 figures that are to be represented in y-axis; <strong>2 figures that are to be represented in x-axis; and <strong>7 represented variables. <h1>The final program will be: <pre><code>%% Continuous t = [0:.001:.06]; Y = sinewave(10,50,t); subplot(4,2,1); plot(t,Y); xlabel('Original Signal - Continuous') %% Discrete n = (0:20); f = 50 fs = 10*f ts = 1/fs X = sinewave(10,50,n*ts); subplot(4,2,2); stem(X) xlabel('Discrete'); %% Time Shifting: Advance t0 = 2; X1 = sinewave(10,50,(n*ts)-t0); subplot(4,2,3); stem((n*ts)-t0,X1); xlabel('Time Shifting: Advance') %% Time Shifting: Delay t0 = -2; X2 = sinewave(10,50,(n*ts)-t0); subplot(4,2,4); stem((n*ts)-t0,X2); xlabel('Time Shifting: Delay') %% Time Reversal: Advance t0 = 2; X3 = sinewave(10,50,(-1*n*ts)-t0); subplot(4,2,5); stem((n*ts)-t0,X3); xlabel('Time Reversal: Advance') %% Time Reversal: Delay t0 = -2; X4 = sinewave(10,50,(-1*n*ts)-t0); subplot(4,2,6); stem((n*ts)-t0,X4); xlabel('Time Reversal: Delay') %% Time Scaling: Expand a = .5; t = [0:.001:.06]; X5 = sinewave(10,50,a*(n*ts)); subplot(4,2,7); stem((n*ts),X5); xlabel('Time Scaling: Expand') %% Time Scaling: Compress a = 2; t = [0:.001:.06]; X6= sinewave(10,50,a*n*ts); subplot(4,2,8); stem(n*ts,X6); xlabel('Time Scaling: Compress') <h1>See the difference for yourself: <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png" alt="13.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png 2x" /> <h1>References <ul> <li><strong>CTandDT - Digital Signal Processing by Engineer Junard Kaquilala <hr /> <hr /> <p dir="auto"><center>Do not stop learning just because you found it hard<center> <hr /> <h3><center><span>this is <a href="/@sissyjill">@sissyjill at your service
#ulog (Tutorial @4): Unleashing the Capabilities of MATLAB #3 (Basic Signal Operations: Discrete-Time Signal)
<h3><center>Be a productive human being! <hr /> <h1>What is MATLAB? <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png" alt="logo.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmTTKM8xGdRPqsdja9XuWuXtLcJUEtBTMR9NFsyorQVC6W/logo.png 2x" /> <blockquote> <p dir="auto">MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment. A proprietary programming language developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of¬ algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, C#, Java, Fortran and Python. ---Wikipedia <blockquote> <p dir="auto">MATLAB is specifically designed for engineers and scientists. It possesses a matrix-based language that allows natural act or instance of representing a computational mathematics. <blockquote> <p dir="auto">MATLAB combines a desktop environment tuned for iterative analysis and design processes with a programming language that expresses matrix and array mathematics directly. <p dir="auto">We can say that MATLAB is specifically designed to provide multi-paradigm numerical computing environment for engineers and scientists. Since this type of computing environment possesses a matrix-based language therefore it allows natural instances in representing a computational mathematics. <hr /> <h1>A glimpse in the Capabilities of MATLAB <h3>Click the words with the font color of green to be directed to some posts I’ve already exposed about MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/unleashing-the-capabilites-of-matlab-1" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 001) Unleashing the Capabilities of MATLAB #1 <h6>In the post above, you’ll be able to understand the big difference between a continuous-time signal and a discrete-time signal using MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/ulog-tutorial-002-how-to-install-activate-and-run-matlab" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 002): How to Install, Activate, and Run MATLAB 😲 <h6>In the post above, you’ll be able to know how to <strong>INSTALL, <strong>ACTIVATE, and <strong>RUN MATLAB. <ul> <li>Click <a href="https://steemit.com/steemstem/@sissyjill/unleashing-the-capabilities-of-matlab-2-basic-signal-operations-continuous-time-signal" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#ulog (Tutorial @ 003): Unleashing the Capabilities of MATLAB #2 (Basic Signal Operations: Continuous-Time Signal) <h6>In the post above, you’ll be able to know how to Apply the BASIC SIGNAL OPERATIONS in a CONTINUOUS-TIME SIGNAL using MATLAB. <hr /> <p dir="auto">These days I am exploring more of this amazing and interesting application and as I am learning, I kind of wanting to share it to you so here I am. So, without further ado, this time, we are going to learn about the <strong>Basic Signal Operations of <strong>Digital Processing Signals <hr /> <h1>What are the Basic Signal Operations of Digital Processing Signals? <ul> <li><p dir="auto"><strong>Time Shifting<br /> Time Shifting Operation is the result you get when you change the positioning of the signal without affecting its amplitude. It can either be delayed or advanced compared to the original signal. To change the positioning of a signal you just need to subtract the fundamental period from the time. <li><p dir="auto"><strong>Time Reversal<br /> Time Reversal Operation is basically the reflection or the reverse of the original signal. To reverse a signal, you just need to multiply time with negative one. <li><p dir="auto"><strong>Time Scaling<br /> Time Scaling Operation is the result when the time of the original signal is being multiplied by a time-variable or a scaling factor. The original signal can either be stretched or compressed. <hr /> <p dir="auto">To understand more about the basic signal operations, let us construct codes that will show their graphs by using MATLAB. <hr /> <hr /> <h1>Things to consider in using MATLAB <ul> <li><p dir="auto">Put Two Percent-Signs (%%)<br /> Always put two percent-signs to create sections of the program. This is necessary when we are dealing with various elements and codes that are meant for different graphs or commands. This allows us to run the program separately from other sections. <li><p dir="auto">MATLAB is Sequential Type of Programming Platform<br /> This factor is very important to remember since the program may not be able to run if the inputted values are not in sequence. Therefore, there is a sequence that is in need to be followed. It is essential to first encode the values of every variables you are to represent before encoding a function or equation. <li><p dir="auto">Put Colon (:) to Create Matrix<br /> Put colon whenever you want to construct a matrix. Let us use time as an example. Time is an independent variable and since it has no ending, for us to establish limits we need to construct a matrix. So, how to construct a matrix? Just follow <strong>start:interval:end. <li><p dir="auto">Variables Represented are Limited<br /> The only variables that can be represented in a MATLAB are letters, numbers, and dollar sign. <li><p dir="auto">Parenthesis is in Need to Analyze the Program<br /> When you are about to call or analyze the program you made, you need to enclose the Variable you represent with parenthesis. <li><p dir="auto">plot(<em>variable represented)<br /> That is what you need to encode when you are going to analyze a program for Continuous-Time Signal. <li><p dir="auto">stem(<em>variable represented)<br /> That is what you need to encode when you are going to analyze a program for Discrete-Time Signal. <li><p dir="auto">subplot(y,x,n)<br /> To subplot programs, you need to consider the number of figures that are to be represented in y-axis, x-axis and the number of variables to be represented. <strong>y is for the number of figures that are to be represented in y-axis; <strong>x is for the number of figures that are to be represented in x-axis; and <strong>n is for the number of variables to be represented. <hr /> <h1>Sneak Peak for This Topic: <ul> <li>Our original signal is the Continuous-Time Signal and we’ll have sinewave as an example since it is common and easy to understand. Sinewave is equal to <pre><code>A*sin(2*pi*f*t); <ul> <li>This time we are going to have Discrete-Time Signal so, we are to convert it simply by replacing time with the product of number of samples and the sampling time. It’ll look like this: <pre><code>A*sin(2*pi*f*n*ts); <ul> <li>Since we have too many functions and sections to perform so you’ll also be learning how to save a function and how to call it. <h6>This function will be used throughout the entire program <ul> <li>When plotting a called function you must use <pre><code>plot(*time*,*variable*); ##for Continuous-Time Signal <pre><code>stem(*time*,*variable*); ##for Discrete-Time Signal <ul> <li><p dir="auto">We use xlabel('<em>Your preferred name') to label every section. <li><p dir="auto">Our fundamental periods are denoted with t0. <li><p dir="auto">Our scaling factor is denoted with a. <li><p dir="auto">We’ll be having eight sections in this program. <hr /> <hr /> <h1>Using MATLAB <hr /> <ul> <li><p dir="auto">Open your MATLAB<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png" alt="intro.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmRtgQ4zTJ32CXY3TNmFvfvFM41qmDGLV6opRvo5ZQ91xv/intro.png 2x" /> <li><p dir="auto">Go to the <strong>MATLAB Editor to start encoding the program<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png" alt="01.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmNutodEZHiNFcyxbQTW4jKLMR19MF28TL9TuXpzy125FU/01.png 2x" /> <h6>First, we are going to plot our Continuous-Time Signal. Then we are going to apply all the operations to Discrete-Time Signal and compare all their graphs. <hr /> <ul> <li>The whole program will begin by creating a function. So, in the editor, type the codes I encoded below <pre><code>function xt = sinewave(A,f,t) xt = A*sin(2*pi*f*t) end <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png" alt="02.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmQjWQGNpbjw1LtPcecmkREk1TFn6rkYHB2sHrRobrbg2x/02.png 2x" /> <ul> <li><p dir="auto">Save it using <strong>”sinewave”<br /> <img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png" alt="03.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmP7XLSAben4ibRtym622w4QApXBfzkMijjPUmpoAJ9Fax/03.png 2x" /> <li><p dir="auto">Open another Editor and let us start with our Original Signal <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png" alt="04.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmUPzCAWhAeKZFpzRaD68mS75ndW3rpZ1pUd7o7easSgd7/04.png 2x" /> <hr /> <h6>Since I stated above that sinewave is what we are going to use as an example, so we’ll first create our first section. This section will be our original signal. <pre><code>%% Continuous <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need. But this time, since we are calling a function from the first editor then time will only be the value we need to be encoded first before encoding anything else in the program <pre><code>t = [0:.001:.06]; <h6>Now let us encode the equation of the first variable we are to represent. And you may be curious about its structure but that is what our equations will look like because once again, we are calling the function we made in the first editor. <pre><code>Y = sinewave(10,50,t); <h6>Since the goal is to represent “Y” we’ll follow the rules above. <pre><code>plot(t,Y); <h6>To recognize the section, let us label it. <pre><code>xlabel('Original Signal - Continuous') <h5>So, the first section is: <pre><code>%% Continuous t = [0:.001:.06]; Y = sinewave(10,50,t); plot(t,Y); xlabel('Original Signal - Continuous') <h6>Then press the <strong><em>"Run"icon to run the program. <h6>The graph below is the representation of the Continuous-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png" alt="05.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmUGAStuyzcbG516spjBGMkQ1KAKX69sjcfidTrjzMh46E/05.png 2x" /> <hr /> <h6>Since I stated above that we are to apply operations with Discrete-Time Signal so we’ll create our second section. <pre><code>%% Discrete <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <pre><code>n = (0:20); f = 50; fs = 10*f; ts = 1/fs; <h6>Now let us encode the equation of the second variable we are to represent. And you may be curious about its structure but that is what our equations will look like because once again, we are calling the function we made in the first editor. <pre><code>X = sinewave(10,50,n*ts); <h6>Since the goal is to represent “X” we’ll follow the rules above. <pre><code>stem(X); <h6>To recognize the section, let us label it. <pre><code>xlabel('Discrete'); <h5>So, the second section is: <pre><code>%% Discrete n = (0:20); f = 50 fs = 10*f ts = 1/fs X = sinewave(10,50,n*ts); stem(X) xlabel('Discrete'); <h6>Then press the <strong><em>"Run"icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png" alt="06.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmQRCkFBcr5kAhrKw346EoSirQSukwvdRn3753apLeERch/06.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Shifting Operations to show us the difference between ADVANCE and DELAY. These will serve as our third and fourth sections. Time Shifting results when we subtract periods (t0) from our time (t) <h6>Starting with ADVANCE, we are going to provide another section. <pre><code>%% Time Shifting: Advance <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to ADVANCE when the value of our (t0) is greater than zero. <pre><code>t0 = 2; <h6>Now let us encode the equation of the third variable we are to represent. <pre><code>X1 = sinewave(10,50,(n*ts)-t0); <h6>Since the goal is to represent “X1” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X1); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Shifting: Advance') <h5>So, the third section is: <pre><code>%% Time Shifting: Advance t0 = 2; X1 = sinewave(10,50,(n*ts)-t0); stem((n*ts)-t0,X1); xlabel('Time Shifting: Advance') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png" alt="07.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmeyzPMsrTdETJFgbnaE5aAv1cBQ5nQRwo7t8VA2AjMHKy/07.png 2x" /> <hr /> <h6>This time, we’ll be having the DELAY. We are going to provide another section. <pre><code>%% Time Shifting: Delay <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to DELAY when the value of our (t0) is less than zero. <pre><code>t0 = -2; <h6>Now let us encode the equation of the fourth variable we are to represent. <pre><code>X2 = sinewave(10,50,(n*ts)-t0); <h6>Since the goal is to represent “X2” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X2); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Shifting: Delay') <h5>So the fourth section is: <pre><code>%% Time Shifting: Delay t0 = -2; X2 = sinewave(10,50,(n*ts)-t0); stem((n*ts)-t0,X2); xlabel('Time Shifting: Delay') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png" alt="08.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmVyee4feSzKTqQnKWtaqtVjyfyBFDGz1XLRUxEPLymKmt/08.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Reversal Operations to show us the difference between the Reversal of ADVANCE and the Reversal of DELAY. Time Reversal results when multiplying negative one (-1) to our time (t) <h6>Starting with ADVANCE, we are going to provide another section. <pre><code>%% Time Reversal: Advance <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to ADVANCE when the value of our (t0) is greater than zero. <pre><code>t0 = 2; <h6>Now let us encode the equation of the fifth variable we are to represent. <pre><code>X3 = sinewave(10,50,(-1*n*ts)-t0); <h6>Since the goal is to represent “X3” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X3); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Reversal: Advance') <h5>So the fifth section is: <pre><code>%% Time Reversal: Advance t0 = 2; X3 = sinewave(10,50,(-1*n*ts)-t0); stem((n*ts)-t0,X3); xlabel('Time Reversal: Advance') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png" alt="09.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmWdMyPsGVQ9kTnEWgnbZtGo7NtEG3H8UbWKCWtMFwKwWD/09.png 2x" /> <hr /> <h6>This time, we’ll be having the DELAY. We are going to provide another section. <pre><code>%% Time Reversal: Delay <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is shifted to DELAY when the value of our (t0) is less than zero. <pre><code>t0 = -2; <h6>Now let us encode the equation of the sixth variable we are to represent. <pre><code>X4 = sinewave(10,50,(-1*n*ts)-t0); <h6>Since the goal is to represent “X4” we’ll follow the rules above. <pre><code>stem((n*ts)-t0,X4); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Reversal: Delay') <h5>So the sixth section is: <pre><code>%% Time Reversal: Delay t0 = -2; X4 = sinewave(10,50,(-1*n*ts)-t0); stem((n*ts)-t0,X4); xlabel('Time Reversal: Delay') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png" alt="10.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbQxf9EtCXNncac7LXxzPbotncNyRveC3MJimfQLMea3r/10.png 2x" /> <hr /> <ul> <li>We’ll be having two Time Scaling Operations to show us the difference between EXPANDED and COMPRESSED version of the Original Signal. Time Scaling results when we multiply a scaling factor (a) to our time (t) <h6>Starting with EXPANDED; we are going to provide another section. <pre><code>%% Time-Scaling: Expanded <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is scaled to EXPAND when the value of our (a) is greater than zero but less than 1. <pre><code>a = .5; <h6>Now let us encode the equation of the seventh variable we are to represent. <pre><code>X5 = sinewave(10,50,a*(n*ts)); <h6>Since the goal is to represent “X5” we’ll follow the rules above. <pre><code>stem((n*ts),X5); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Scaling: Expanded') <h5>So the seventh section is: <pre><code>%% Time Scaling: Expanded a = .5; t = [0:.001:.06]; X5 = sinewave(10,50,a*(n*ts)); stem((n*ts),X5); xlabel('Time Scaling: Expanded') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png" alt="11.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbHC3k6UBkGoVDEVwkBJD9uDCPXzoQPZzTK4zLm7Kf8fh/11.png 2x" /> <hr /> <h6>This time, we’ll be having the COMPRESSED version of the original signal. We are going to provide another section. <pre><code>%% Time-Scaling: Compressed <h6>We are already aware that MATLAB is sequential, so we’ll input the important values that we need except for the values we already inputted in our original signal. <h6>Signal is scaled to COMPRESS; when the value of our (a) is greater than one. <pre><code>a = 2; <h6>Now let us encode the equation of the eighth variable we are to represent. <pre><code>X6= sinewave(10,50,a*n*ts); <h6>Since the goal is to represent “X6” we’ll follow the rules above. <pre><code>stem(n*ts,X6); <h6>To recognize the section, let us label it. <pre><code>xlabel('Time Scaling: Compressed') <h5>So the eighth section is: <pre><code>%% Time Scaling: Compressed a = 2; t = [0:.001:.06]; X6= sinewave(10,50,a*n*ts); stem(n*ts,X6); xlabel('Time Scaling: Compressed') <h6>Then press the <strong><em>"Run" icon to run the program. <h6>The graph below is the representation of the Discrete-Time Signal we encoded. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png" alt="12.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmY1JT919sNds3bdqPkMdb5HNnvw4BbB43FkRyqpCQ4nWg/12.png 2x" /> <hr /> <h1>SUBPLOTTING <p dir="auto">This time, we’ll be comparing the graph from each other to see their difference and to prove the validity of the operations. We are going to have <strong>4 figures that are to be represented in y-axis; <strong>2 figures that are to be represented in x-axis; and <strong>7 represented variables. <h1>The final program will be: <pre><code>%% Continuous t = [0:.001:.06]; Y = sinewave(10,50,t); subplot(4,2,1); plot(t,Y); xlabel('Original Signal - Continuous') %% Discrete n = (0:20); f = 50 fs = 10*f ts = 1/fs X = sinewave(10,50,n*ts); subplot(4,2,2); stem(X) xlabel('Discrete'); %% Time Shifting: Advance t0 = 2; X1 = sinewave(10,50,(n*ts)-t0); subplot(4,2,3); stem((n*ts)-t0,X1); xlabel('Time Shifting: Advance') %% Time Shifting: Delay t0 = -2; X2 = sinewave(10,50,(n*ts)-t0); subplot(4,2,4); stem((n*ts)-t0,X2); xlabel('Time Shifting: Delay') %% Time Reversal: Advance t0 = 2; X3 = sinewave(10,50,(-1*n*ts)-t0); subplot(4,2,5); stem((n*ts)-t0,X3); xlabel('Time Reversal: Advance') %% Time Reversal: Delay t0 = -2; X4 = sinewave(10,50,(-1*n*ts)-t0); subplot(4,2,6); stem((n*ts)-t0,X4); xlabel('Time Reversal: Delay') %% Time Scaling: Expand a = .5; t = [0:.001:.06]; X5 = sinewave(10,50,a*(n*ts)); subplot(4,2,7); stem((n*ts),X5); xlabel('Time Scaling: Expand') %% Time Scaling: Compress a = 2; t = [0:.001:.06]; X6= sinewave(10,50,a*n*ts); subplot(4,2,8); stem(n*ts,X6); xlabel('Time Scaling: Compress') <h1>See the difference for yourself: <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png" alt="13.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmbLX5x95snd2wWekBFtLYVpFWyGMZbYzHd9LmX6x7THMe/13.png 2x" /> <h1>References <ul> <li><strong>CTandDT - Digital Signal Processing by Engineer Junard Kaquilala <hr /> <hr /> <p dir="auto"><center>Do not stop learning just because you found it hard<center> <hr /> <h3><center><span>this is <a href="/@sissyjill">@sissyjill at your service