MATLAB Questions and Answers – Operations on Signals – 2

This set of MATLAB Question Paper focuses on “Operations on Signals – 2”.

1. What is the output of the following code?

plot([-5:1:5],tripuls([-4:1:4])

a) Error
b) Generates a triangular pulse signal
c) Generates a sawtooth signal
d) Cannot be determined
View Answer

Answer: a
Explanation: The length of the first vector given as an input to the plot command is not equal to the length of the second vector given as an input. Hence, the above code will result in an error. If the first vector was ranging from [-4:1:4], the output would’ve been Generates a triangular pulse signal only.
advertisement
advertisement

2. What is the output of the following code?

b={1 2 3};
c={ 1 2 3}
b+c

a) Error
b) { 2 4 6 }
c) { 1 2 3 }
d) Cannot be determined
View Answer

Answer: a
Explanation: Mathematical operators like ‘+’, ‘-‘ do not work on cellular arrays. Hence, the above code will lead to an error in MATLAB.
Note: Join free Sanfoundry classes at Telegram or Youtube

3. What is the output of the following code?

advertisement
t=[0:1:2];
plot(t,p);
hold;
plot(-t,p);

a) A mirror image of ramp function from 0 to 2 units in time
b) A ramp function from 0 to 2 units in time and it’s a mirror image in the same window
c) A ramp function from 0 to 2 units in time
d) Error
View Answer

Answer: b
Explanation: Since we have used the hold command, we can now plot multiple graphs in the same window. The 1st plot command generates a ramp function from 0 to 2 units in time while the 2nd ramp function generates its mirror image in the same window. There is no error in the above code.
advertisement

4. Discrete time convolution is not possible in MATLAB.
a) True
b) False
View Answer

Answer: b
Explanation: We need to define the signal in terms of vectors and then we can give them as inputs to the conv() command. This will result in the discrete time convolution.

5. plot([0:1:8],[rectpulse(1,9)]’) and plot([0:1:8],ones(1,9)) will generate the same graph.
a) True
b) False
View Answer

Answer: a
Explanation: ‘rectpulse(1,9)’ generates a column vector of 9 1’s. Since we have transposed it, the resultant is a row vector of 9 1s. ‘ones(1,9)’ also generates 9 1’s as a row vector. Thus, the above codes will result in the same graph.

6. If x(t-5)=0 for t<5 = A for t>=5, the signal is ___________
a) Causal
b) Symmetric
c) Linear, Time Invariant and Causal
d) Cannot be determined
View Answer

Answer: a
Explanation: The signal given to us is delayed by 5 units in time. If we advance the signal by 5 units, the signal amplitude is 0 for t<0 but A for t>=0. Hence, the signal will be causal.

7. What is the output of the following code?

>>p=[zeros(1,5),ones(1,6)];
>> t=0:1:10;
>> plot(t,p);

a) r(t-5)-r(t-6)-u(t-10)
b) r(t-5)-u(t-6)-u(t-10)
c) r(t-5)-u(t-6)-r(t-10)
d) r(t-5)-r(t-6)-r(t-10)
View Answer

Answer: a
Explanation: The signal changes from 0 to 1 from t=5 to t=6 seconds. This indicates a ramp function starting from t=5 seconds. But again it remains constant till t=10 so it signifies that the same signal is subtracted by a ramp function at t=6 seconds. Finally the signal ends at t=10 seconds so a unit step signal gets subtracted from the previous signal at t=10 seconds.

8. What is the output of the following code?

[l,m]=deconv([4 6 8],[2 3 4])

a) l=2,m=0
b) m=2,l=0
c) l=m=2
d) Error
View Answer

Answer: a
Explanation: The deconv() command is used for polynomial division. Since it will first return a quotient, l=2. It will next return the remainder which is 0 in this case and hence, m=0.

9. What is the output of the following code?

stem([0:1:19],[zeros(1,5) [rectpulse(1,5)] zeros(1,5) 2*[rectpulse(1,5)]])

a) Error in the input of the y axis
b) A function whose step size increases to 1 at t=5 and to 2 at t=15
c) A function whose step size increases to 1 at t=4 and to 2 at t=14
d) Syntactical Error
View Answer

Answer: a
Explanation: The rectpulse command generates a column vector so it cannot be concatenated with row vectors ie with zeros. If we had taken the transpose of the vectors generated due to the rectpulse command. It leads to an error.

10. What is the output of the following code?

a=[zeros(1,4) [rectpulse(1,5)]zeros(1,6) 2*[rectpulse(1,9)]];
stem([0:1:22],a];

a) Error in the input of the y axis
b) A function whose step size increases to 1 at t=5 and to 2 at t=15
c) A function whose step size increases to 1 at t=4 and to 2 at t=14
d) Error in the input of the x axis
View Answer

Answer: d
Explanation: The length of the signal to be plotted, which is given as the y axis, is 24 while the length of the x axis is 23. This leads to an error since both the vectors has to be of same length.

Sanfoundry Global Education & Learning Series – MATLAB.

To practice all questions papers on MATLAB, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.