First MATLAB Program

MATLAB Tutorial

First MATLAB Program

Your first MATLAB program helps you understand how to write, run, and view output in MATLAB.

MATLAB is developed by MathWorks.


1: Hello World in MATLAB

 Step 1: Open MATLAB Editor

  • Click New Script

  • A blank editor window opens


 Step 2: Write the Program


 Step 3: Save the File

  • File Name: hello.m

  • Location: Current Folder


 Step 4: Run the Program

  • Click Run

  • Or press F5


 Output (Command Window)

Hello, MATLAB World!

2: Simple Addition Program

 Output

30

3: Square of a Number

 Output

25

Program 4: Simple Plot Program


This program creates a basic graph, showing MATLAB’s plotting power 📈


Important Points for Beginners

  • MATLAB is case-sensitive

  • Statements end with a semicolon ; to suppress output

  • Scripts are saved with .m extension

  • Use disp() to display text or values


What You Learned

  •  How to write a MATLAB program
  •  How to run a script
  •  How to display output
  •  Basic calculation & plotting

You may also like...