MATLAB Arithmetic Operators

MATLAB Tutorial

➕➖✖️➗ MATLAB Arithmetic Operators

Arithmetic operators in MATLAB are used to perform basic mathematical calculations on numbers, vectors, and matrices.

MATLAB is developed by MathWorks.


🔹 List of MATLAB Arithmetic Operators

Operator Name Description
+ Addition Adds two values
- Subtraction Subtracts one value from another
* Multiplication Matrix multiplication
/ Right division Divides matrices or numbers
\ Left division Solves linear equations
.* Element-wise multiplication Multiplies element by element
./ Element-wise division Divides element by element
.^ Element-wise power Power of each element
^ Power Matrix power

🧪 Examples with Output


1️⃣ Addition (+)


Output

15

2️⃣ Subtraction (-)


Output

12

3️⃣ Multiplication (*)


Output

19 22
43 50

📌 This is matrix multiplication.


4️⃣ Division (/)


Output

5

5️⃣ Left Division (\)


Output

2
3

📌 Used to solve linear equations.


6️⃣ Element-wise Multiplication (.*)


Output

4 10 18

7️⃣ Element-wise Division (./)


Output

5 5 6

8️⃣ Power Operator (^ and .^)

🔸 Scalar Power


Output

25

🔸 Element-wise Power


Output

1 4 9

⚠️ Important Notes

  • Use *, /, ^ for matrix operations

  • Use .*, ./, .^ for element-wise operations

  • Matrix dimensions must be compatible


🎯 Interview Questions: MATLAB Arithmetic Operators

🔹 Q1. What is the difference between * and .*?

Answer:
* performs matrix multiplication, while .* performs element-wise multiplication.


🔹 Q2. Difference between / and ./?

Answer:
/ is matrix right division, ./ is element-wise division.


🔹 Q3. What does \ operator do?

Answer:
Solves linear equations (A \ B).


🔹 Q4. Difference between ^ and .^?

Answer:
^ is matrix power, .^ is element-wise power.


🔹 Q5. Can arithmetic operators be used on vectors?

Answer:
Yes, using element-wise operators.


🔹 Q6. What happens if matrix dimensions don’t match?

Answer:
MATLAB gives a dimension mismatch error.


Summary Table

Operator Use
+ - Addition / Subtraction
* / \ Matrix operations
.* ./ .^ Element-wise operations
^ Matrix power

You may also like...