MATLAB Programs for Beginners

MATLAB Tutorial

💻 MATLAB Programs for Beginners

These MATLAB Programs for Beginners help you practice syntax, logic, loops, functions, arrays, and plotting.

MATLAB is developed by MathWorks.


1️⃣ Hello World



 

Output

Hello MATLAB

2️⃣ Add Two Numbers



 

Output

30

3️⃣ Even or Odd



 

Output

Odd

4️⃣ Largest of Three Numbers



 

Output

25

5️⃣ Factorial of a Number



 

Output

120

6️⃣ Fibonacci Series



 

Output

0 1 1 2 3 5 8

7️⃣ Check Prime Number



 

Output

1

8️⃣ Reverse a Number



 

Output

4321

9️⃣ Sum of Array Elements



 

Output

100

🔟 Matrix Addition



 

Output

6 8
10 12

1️⃣1️⃣ Linear Search



 

Output

1

1️⃣2️⃣ Simple 2D Plot



 

Output: Graph of y = x²


1️⃣3️⃣ User-Defined Function (Square)



 

Call:



 

Output

36

1️⃣4️⃣ Count Vowels in a String



 

Output

5

🎯 Common Interview Questions (Beginner Level)

Q1. Difference between * and .*?
A: * matrix multiply, .* element-wise multiply.

Q2. How to create a loop?
A: for, while.

Q3. How to write a function?
A: Use function keyword in an .m file.

Q4. How to plot data?
A: plot(x,y).

Q5. How to find array sum/maximum?
A: sum(), max().


✅ Practice Tips

  • Start with arrays & loops

  • Prefer vectorized code

  • Use help / doc for functions

  • Practice plotting & file I/O basics