NM Lab 01
NM Lab 01
Introduction to MATLAB
Starting with MATLAB
1- MATLAB Windows:
MATLAB windows contain four smaller windows are as:
Command Window
The Command Window enables you to enter individual statements at the command line, indicated by
the prompt (>>). As you enter statements, the Command Window displays the results.
This table describes some additional actions that you can perform in the Command Window.
Enter multiple statements Enter the multiple statements at the command line, pressing Shift+Enter between statements.
on multiple lines before
running any of the This key combination is unnecessary when you enter a paired keyword statement on multiple lines, such
statements. as for and end.
Editor Window
The ‘Editor Window’ in MATLAB is where you write, edit, and save code files, such as:
It’s part of MATLAB’s IDE (Integrated Development Environment) and is especially useful for developing
longer code, debugging, and organizing projects.
Feature Description
Syntax Highlighting Colors keywords, comments, and variables for better readability.
Run Section Run specific sections of code using "%%" section breaks.
Live Scripts (.mlx) Mix code, output, formatted text, equations, and images interactively.
Help Window
The Help Window in MATLAB is a built-in interface that provides documentation, examples,
explanations, and guides for using MATLAB functions, toolboxes, and features. It's essentially your go-to
place when you need to understand how something in MATLAB works.
Working in the Command Window
The Semicolon:
Typing %:
When the symbol is used at the beginning of a line, the line is designated as a comment.
Sum Expr = x + y
Difference Expr = x - y
Product Expr = x * y
Division Expr = x / y
Power Expr = x^2 + y^2
MATLAB as a Calculator
Display Formats
MATLAB has several other formats for displaying numbers.
Sqrt(x)
Nthroot(x,n)
Exp(x)
Abs(x)
Log(x)
Factorial(5)
Trignometric Math Functions
Trigonometric math functions are as:
Sind(x)
Cosd(x)
Tand(x)
Cotd(x)
Round(x)
Fix(x)
Ceil(x)
Floor(x)
Rem(x)
Sign(x)