Built-in Functions in MATLAB

MATLAB Tutorial

🧠 Built-in Functions in MATLAB

Built-in functions in MATLAB are predefined functions that perform common tasks such as mathematical calculations, array operations, data analysis, and plotting.

They help write short, fast, and readable code.
MATLAB is developed by MathWorks.


🔹 What Are Built-in Functions?

Built-in functions:

  • Are already available in MATLAB

  • Do not require user definition

  • Are optimized for speed and accuracy

  • Work on scalars, vectors, and matrices


1️⃣ Mathematical Built-in Functions

🔸 Example: sqrt()

Output

4

🔸 Example: pow2() / power()

Output

9

🔸 Common Math Functions

FunctionDescription
abs()Absolute value
sqrt()Square root
power()Power
round()Round to nearest
floor()Round down
ceil()Round up
mod()Remainder

2️⃣ Trigonometric Functions

(All angles in radians)

Output

1
1
1

3️⃣ Statistical Built-in Functions


 

Output

30
150
50
10

4️⃣ Matrix & Array Built-in Functions

🔸 Size & Length

Output

2 3
3

🔸 Sorting

Output

1 2 3

🔸 Transpose

A'

5️⃣ Logical & Relational Functions

Output

1
1

6️⃣ String Built-in Functions

Output

"MATLAB"
"matlab"
6

7️⃣ Plotting Built-in Functions

📌 Creates a simple graph 📈


🔍 How to Find Built-in Functions

help sin
doc mean
lookfor matrix

🎯 Interview Questions: Built-in Functions in MATLAB

🔹 Q1. What are built-in functions?

Answer:
Predefined functions available in MATLAB for common operations.


🔹 Q2. Give examples of mathematical built-in functions.

Answer:
sqrt(), abs(), round(), mod().


🔹 Q3. Which function finds the average of values?

Answer:
mean().


🔹 Q4. What is the use of size()?

Answer:
Returns rows and columns of an array.


🔹 Q5. Which function converts text to uppercase?

Answer:
upper().


🔹 Q6. Are built-in functions faster than user-defined ones?

Answer:
Yes, they are optimized.


🔹 Q7. How do you get help for a function?

Answer:
Using help or doc.


Summary

  • Built-in functions save time

  • Cover math, arrays, strings, plots

  • Highly optimized and reliable

  • Essential for MATLAB programming

You may also like...