logo
  • Home
  • Test & Rank
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Mining
  • Marine
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Jobs
  • Contact

MATLAB Multiple Choice Questions | MCQs | Quiz

MATLAB Interview Questions and Answers
Practice MATLAB questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Input & Output
•   Arithmetic - 1
•   Arithmetic - 2
•   Algebra
•   Managing Variables
•   Input Errors - 1
•   Input Errors - 2
•   Variables & Assignments
•   Solving Equations
•   Vectors & Matrices - 1
•   Vectors & Matrices - 2
•   Functions
•   Graphics
•   Statistics
•   Plotting Multiple Curves
•   The MATLAB Interface
•   M Files
•   Loops
•   Presenting Results
•   Fine Tuning
•   Suppressing Output
•   Data Classes
•   Functions & Expressions
•   Complex Arithmetic
•   Linear Systems
•   Differentiation - 1
•   Differentiation - 2
•   Integration - 1
•   Integration - 2
•   Limits - 1
•   Limits - 2
•   Sums & Products - 1
•   Sums & Products - 2
•   Default Variables
•   Fourier Analysis - 1
•   Fourier Analysis - 2
•   Random No's Generation
•   Sparse Matrices - 1
•   Sparse Matrices - 2
•   Two Dimensional Plots - 1
•   Two Dimensional Plots - 2
•   Three Dimensional Plots
•   Customizing Graphics - 1
•   Customizing Graphics - 2
•   Branching - 1
•   Branching - 2
•   Logical Expressions - 1
•   Logical Expressions - 2
•   More about Loops - 1
•   More about Loops - 2
•   Input & Output Command-1
•   Input & Output Command-2
•   Screen Output - 1
•   Screen Output - 2
•   Evaluation - 1
•   Evaluation - 2
•   Debugging
•   Modeling - 1
•   Modeling - 2
•   Simulation - 1
•   Simulation - 2
•   Calling External Functions
•   Toolbox Distribution - 1
•   Toolbox Distribution - 2
•   Performance & Memory - 1
•   Performance & Memory - 2
•   System Commands - 1
•   System Commands - 2
•   Unexpected Outputs
•   Syntax Error - 1
•   Syntax Error - 2
•   Spelling Error - 1
•   Spelling Error - 2
•   Laplace Transform - 1
•   Laplace Transform - 2
•   Control Systems - 1
•   Control Systems - 2
•   Impulse Response - 1
•   Impulse Response - 2
•   Signals Operations - 1
•   Signals Operations - 2
•   Convolution - 1
•   Convolution - 2
•   Z Transform - 1
•   Z Transform - 2

Best Reference Books

MATLAB Books

MATLAB Tests

Certification Test
Internship Test
Job Test
All Tests
Top Rankers
Practice Test 1
Practice Test 2
Practice Test 3
Practice Test 4
Practice Test 5
Practice Test 6
Practice Test 7
Practice Test 8
Practice Test 9
Practice Test 10
Mock Test 1
Mock Test 2
Mock Test 3
Mock Test 4
Mock Test 5
Mock Test 6
Mock Test 7
Mock Test 8
Mock Test 9
Mock Test 10
« Prev Page
Next Page »

MATLAB Questions and Answers – Syntax Error – 1

Posted on December 12, 2018 by Manish

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Syntax Error – 1”.

1. What is the error in the following?

advertisement
input(“pop”)

a) None
b) “”
c) Parentheses
d) No such command
View Answer

Answer: b
Explanation: The input to the input command should be within ‘’ and not “”. Double-inverted commas will lead to a syntactical error in MATLAB.

2. What is the error in the following code?

for i={1: 10}
p=a+1
end

a) None
b) {}
c) The : operator
d) Cannot be determined
View Answer

Answer: a
Explanation: MATLAB won’t give any error. but the loop will only run once because we have a syntactical error while defining the conditions for the loop.

3. What is the output of the following code?

limit[1/x,0]

a) NaN
b) Inf
c) Syntactical Error
d) Logical error
View Answer

Answer: c
Explanation: The input to the limit command should be within parentheses. But here, the input is given within []. This leads to an error in MATLAB.
advertisement

4. What is the output of the following code?

length{ 1 2 }

a) Error due to space after 2
b) Error due to {}
c) Syntactical Error
d) 2
View Answer

Answer: c
Explanation: The input to the length function has to be within a parentheses. We don’t see the parentheses here, and we’ll find that this leads to an error in MATLAB.

5. What is the output of the following code?

limit((1 + 1/n)^n,n=Inf)

a) e
b) exp(1)
c) Syntactical Error
d) Cannot be determined
View Answer

Answer: c
Explanation: The correct syntax would be to simply state the limiting value as Inf. This is for new versions of MATLAB. The above code would result in a syntactical error.

6. What is the output of the following code?

A={1 2 3 4}
sum(A)

a) Error
b) 10
c) { 10 }
d) Logical Error
View Answer

Answer: a
Explanation: The sum function doesn’t work on cellular arrays. So the vector A is to be placed within [] to avoid this kind of error.
advertisement

7. What is the output of the following code?

limit({sin(x)/x},x,Inf,right)

a) 0
b) Inf
c) Syntactical error
d) Error due to inconsistency in approaching limit
View Answer

Answer: c
Explanation: There is syntactical error in the above code snippet. The input, right, should be within a pair of single inverted commas. If that was so, there is still error due to inconsistency in approaching the limiting value because we cannot approach positive Infinity from it’s right hand side.

8. What is the output of the following code?

mean({1 2 3})

a) 2
b) Logical Error
c) 1
d) Syntactical Error
View Answer

Answer: d
Explanation: Since the mean command uses the sum command, it also cannot accept cellular arrays as input since this input will go to the sum command first. Hence, the above code will give a syntactical error. Now, if we had given the input, within parentheses, within []- the output would’ve been 2 only.

9. What is the output of the following code?

det({1 2 3; 4 5 6; 7 8 9})

a) 0
b) Syntactical Error
c) A very small value
d) Cannot be determined
View Answer

Answer: b
Explanation: The input to the det command cannot be a cellular array. Since we have given the vector within {}, it results in an error. The output would have been very small value if the mtrix was given within [].

10. What is the output of the following code?

(1 2);

a) A cellular vector of dimension 1*2
b) A vector of dimension 1*2
c) A matrix of dimension 1*2
d) Error
View Answer

Answer: d
Explanation: To create a vector, one needs to give the elements within [] and not within parentheses. Hence, the above code will result in a syntactical error.

11. What is the output of the following code?

p=[1 3 2]; roots[p];

a) Syntactical Error
b) Undefined roots
c) -2,-1
d) Cannot be determined
View Answer

Answer: a
Explanation: The input to the roots command has to be within parentheses. Here, it’s given within [] so it’ll result in a syntactical error. If the input was given within parentheses, the output would’ve been -2,-1.

12. What is the output of the following code?

poly[ 1 2 3]

a) x + 2x + 3x2
b) x3 + 2x2 + x
c) Error
d) Cannot be determined
View Answer

Answer: c
Explanation: The input to the poly command has to be within parentheses. If the input is a vector, one can define the vector, prior to giving it as an input, or give the input like poly([1 2 3]).

13. What is the output of the following code?

polyint[{1 2 3}]

a) Syntactical error due to []
b) Syntactical Error due to {}
c) Logical Error
d) [1/2,1,3]
View Answer

Answer: b
Explanation: The answer would’ve been d. But the input to the polyint command is a cellular array and this results in a syntactical error. But firstly, the input to the polyint command should be within parentheses. But here, the input is within [] which is the first error MATLAB finds.

14. What is the output of the following command?

>> x={1 2 3};
>> t=[1 2 3];
>> plot(x,t)

a) plots a ramp function
b) plots r(t)-r(t-3)
c) Error due to plot
d) Error due to x
View Answer

Answer: d
Explanation: In the above code, x is a cellular array. It will create an error in the working of the plot command since the plot command cannot plot values in cellular arrays. Hence, there is a syntactical error while defining x for the plot command.

15. The input to the polar command is not necessary to be within parentheses.
a) True
b) False
View Answer

Answer: b
Explanation: The polar command is pre-defined in MATLAB and it only takes inputs within a parentheses only. Hence, the above statement is false.

Sanfoundry Global Education & Learning Series – MATLAB.

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

« Prev Page - MATLAB Questions and Answers – Wrong or Unexpected Output
» Next Page - MATLAB Questions and Answers – Syntax Error – 2

« MATLAB Questions and Answers – Wrong or Unexpected Output
MATLAB Questions and Answers – Syntax Error – 2 »
advertisement

Deep Dive @ Sanfoundry:

  1. Simple C Programs
  2. Unix Questions and Answers
  3. Wireless & Mobile Communications Questions & Answers
  4. C++ Questions and Answers
  5. Java Programming Examples on File Handling
  6. C# Programming Examples on Inheritance
  7. C Questions and Answers
  8. MATLAB Questions and Answers
  9. MATLAB Questions and Answers – Customizing and Manipulating Graphics – 2
  10. MATLAB Questions and Answers – Evaluation – 2
Manish Bhojasia
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Facebook | Twitter

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
Terms
Privacy Policy
Jobs
Bangalore Training
Online Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry. All Rights Reserved.