Discuss the purposes of the following commands; subplot(3,1,1) stem(x) in Example 1 where x=[1 2 3 4] n1=-2:1 in Example 2 stem(n1,x) in Example 2
Discuss the purposes of the following commands; subplot(3,1,1) stem(x) in Example 1 where x=[1 2 3 4] n1=-2:1 in Example 2 stem(n1,x) in Example 2
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
- Discuss the purposes of the following commands;
- subplot(3,1,1)
- stem(x) in Example 1 where x=[1 2 3 4]
- n1=-2:1 in Example 2
- stem(n1,x) in Example 2
![s2 =s1;
s1 (find n3>=min( n1 ) ) & ( n3 <=max ( ni ) )==1 ) )=x;
% signal x with the duration gfQutput signal add
s2 (find n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
% signal y with the duration ofQutput signal add
add=s1 +s2; % addition
subplot (3,1,3)
stem(n3.add)
title('Z=X+Y');
axisLI-3 3 0 5]);
Functions Used:
1. min) and max() : used to find minimum and maximum value.
Syntax:
• mino
1. min(x) -returns smallest element in an array if x is an array.
-returns a row vector containing minimum element from each column if x is a matrix
2. min(xy- returns an array with the same size of x and yElements of corresponding indices are checked
and minimum value is
Cstumadx and y must be of same length.
• mex)
1. max(x) -returns largest element in an array ifx is an array.
-returns a row vector containing maximum element from each column if x is a matrix
2. max(x)
-etunS.an array with the same size of x and yElements of corresponding indices are checked and maximum
value
is
CSTACnedx and y must be of same length.
2. zeras) : returns a zero matrix
Synatx:
1. zecosla)
- returns a nxn matrix of zeros.
2. zeros(m.n)
- returns a m xn matrix of zeros.
3. zeros(mnR-) - returns amxnxp.. array fzeros
3. find0 : returns the indices of non zero elements.
Syntax:
1. find(x) – returns the liner indices of non zero elements in an array x
eg, if x= [0405 6]
find(x);
output : 2 4 5
2. find(x.n)- returns atmost first n indices of non zero element in an array
A
relational
operator
also
be
implemented
in
find0
can
For eg: find( x>10) - wil return the indices of element which are greater than 10
4. axis0 : used to change the attributes of the axes
Syntax:
1. axis([xminxmaxyminymax)- set the limits forx and y axes
5.stem): Used for discrete time ploting of signals
Subtraction
With the same program code as of addition replacing arithmetic operator ' we can perform subtraction in
signals.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F259691d1-df6a-4f47-ba3f-41f4faaf2fda%2F5facf2e2-50c4-4101-9cba-24b41ad5db51%2Fmfnftvu_processed.png&w=3840&q=75)
Transcribed Image Text:s2 =s1;
s1 (find n3>=min( n1 ) ) & ( n3 <=max ( ni ) )==1 ) )=x;
% signal x with the duration gfQutput signal add
s2 (find n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
% signal y with the duration ofQutput signal add
add=s1 +s2; % addition
subplot (3,1,3)
stem(n3.add)
title('Z=X+Y');
axisLI-3 3 0 5]);
Functions Used:
1. min) and max() : used to find minimum and maximum value.
Syntax:
• mino
1. min(x) -returns smallest element in an array if x is an array.
-returns a row vector containing minimum element from each column if x is a matrix
2. min(xy- returns an array with the same size of x and yElements of corresponding indices are checked
and minimum value is
Cstumadx and y must be of same length.
• mex)
1. max(x) -returns largest element in an array ifx is an array.
-returns a row vector containing maximum element from each column if x is a matrix
2. max(x)
-etunS.an array with the same size of x and yElements of corresponding indices are checked and maximum
value
is
CSTACnedx and y must be of same length.
2. zeras) : returns a zero matrix
Synatx:
1. zecosla)
- returns a nxn matrix of zeros.
2. zeros(m.n)
- returns a m xn matrix of zeros.
3. zeros(mnR-) - returns amxnxp.. array fzeros
3. find0 : returns the indices of non zero elements.
Syntax:
1. find(x) – returns the liner indices of non zero elements in an array x
eg, if x= [0405 6]
find(x);
output : 2 4 5
2. find(x.n)- returns atmost first n indices of non zero element in an array
A
relational
operator
also
be
implemented
in
find0
can
For eg: find( x>10) - wil return the indices of element which are greater than 10
4. axis0 : used to change the attributes of the axes
Syntax:
1. axis([xminxmaxyminymax)- set the limits forx and y axes
5.stem): Used for discrete time ploting of signals
Subtraction
With the same program code as of addition replacing arithmetic operator ' we can perform subtraction in
signals.
![Operations on Sequences
Addition can be carried out using the tsymbol and plotting will give you the result.
n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1
Addition
4. An array of 1 is created in the respective position which satisfies the condition eg: [111land the other
position will be having a zero value as the s is zero matrix defined by us so that the altogether result will
Example 1:
be an array of 1's and O's eg: [ 1110 0]
and using find function we can find the index values of the position which are 1 now and assigning the
xa[1 2 3 4];
subolot (3,1,1);
variables of input signal there,
stem(x);
Say for example:
xE[1 23] and s1=[0 000 0]
title('x');
We need s(1 2 3) =x ; ig we have to fill the first 3 position of s1 as x elements. Similarly, with the 2nd signal. In
yal1 11 1];
the above condition we are making the elements of s1 equal to1where the elements of x has to be filled in so
Subrlet(3,1,2);
the output will be an array like this s1= [1110 0]. Now using find () function calculating the indices of the
stem(y);
position whose elements are equal to 1.
title('Y');
so that the 5(1 2 3)= x; now the elements of x will be filled in the respective position of s1.Same with the other
signal
subplot (3,1,3);
The complete statement is
stem(z);
s1 (find n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
title('Z=X+Y');
% signal x with the duration of.Qutput signal
Note: In the above example index value of both the signals x and y are the same. If the indexvalues are
s2 (find n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
% signal y with the duration gfoutput signal
different we have to find the range of output by comparing the index values of both signals.
Step 1: After the 2 signals are defined find the duration of output signal using min & max functions
Example 2:
Step 2: Initialize the signals with the duration found, else mismatch in length of the input signals error will be
n1=-2:1;
shown.
X=[1 2 3 4];
Generating a zero matrix of 1 row having elements with length = duration gfoutRut
subplot(3,1,1);
• Making the length of input signals equal by making duration of both equal to that of output
stem(n);
1. For making the duration of input signal equivalent to that of output we have to generate two signals
title('X')
51.52
axis([-3 3 0 5]);
2. s1 and s2 are generated as a zeromatrix using the zeros function having a length, equivalent to the
n2=0:3;
duration found using min and max function earlier in Step 1
yali 11 1];
3. Now the next step is filling in the input elements of x and y in appropriate position of s1 and s2. For it
subplot(3,1,2);
we have to find the indices corresponding to fill gut The logical statement is as follows. Here the
stem(n3,x);
elements satisfying the condition will be assigned 1
title('Y');
axis([-3 3 0 5]);
n3 =min (min(n1)in( n2 ) ) : max ( max ( ni ), max ( n2 ) ); % finding the duration of
output signal
s1 =zecos(1,length (n3) );](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F259691d1-df6a-4f47-ba3f-41f4faaf2fda%2F5facf2e2-50c4-4101-9cba-24b41ad5db51%2F7j0gfae_processed.png&w=3840&q=75)
Transcribed Image Text:Operations on Sequences
Addition can be carried out using the tsymbol and plotting will give you the result.
n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1
Addition
4. An array of 1 is created in the respective position which satisfies the condition eg: [111land the other
position will be having a zero value as the s is zero matrix defined by us so that the altogether result will
Example 1:
be an array of 1's and O's eg: [ 1110 0]
and using find function we can find the index values of the position which are 1 now and assigning the
xa[1 2 3 4];
subolot (3,1,1);
variables of input signal there,
stem(x);
Say for example:
xE[1 23] and s1=[0 000 0]
title('x');
We need s(1 2 3) =x ; ig we have to fill the first 3 position of s1 as x elements. Similarly, with the 2nd signal. In
yal1 11 1];
the above condition we are making the elements of s1 equal to1where the elements of x has to be filled in so
Subrlet(3,1,2);
the output will be an array like this s1= [1110 0]. Now using find () function calculating the indices of the
stem(y);
position whose elements are equal to 1.
title('Y');
so that the 5(1 2 3)= x; now the elements of x will be filled in the respective position of s1.Same with the other
signal
subplot (3,1,3);
The complete statement is
stem(z);
s1 (find n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
title('Z=X+Y');
% signal x with the duration of.Qutput signal
Note: In the above example index value of both the signals x and y are the same. If the indexvalues are
s2 (find n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
% signal y with the duration gfoutput signal
different we have to find the range of output by comparing the index values of both signals.
Step 1: After the 2 signals are defined find the duration of output signal using min & max functions
Example 2:
Step 2: Initialize the signals with the duration found, else mismatch in length of the input signals error will be
n1=-2:1;
shown.
X=[1 2 3 4];
Generating a zero matrix of 1 row having elements with length = duration gfoutRut
subplot(3,1,1);
• Making the length of input signals equal by making duration of both equal to that of output
stem(n);
1. For making the duration of input signal equivalent to that of output we have to generate two signals
title('X')
51.52
axis([-3 3 0 5]);
2. s1 and s2 are generated as a zeromatrix using the zeros function having a length, equivalent to the
n2=0:3;
duration found using min and max function earlier in Step 1
yali 11 1];
3. Now the next step is filling in the input elements of x and y in appropriate position of s1 and s2. For it
subplot(3,1,2);
we have to find the indices corresponding to fill gut The logical statement is as follows. Here the
stem(n3,x);
elements satisfying the condition will be assigned 1
title('Y');
axis([-3 3 0 5]);
n3 =min (min(n1)in( n2 ) ) : max ( max ( ni ), max ( n2 ) ); % finding the duration of
output signal
s1 =zecos(1,length (n3) );
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY