0% found this document useful (0 votes)
20 views2 pages

Essential MATLAB Commands Guide

This document provides a comprehensive list of important MATLAB commands categorized into sections such as Basic Commands, Math Operations, Plotting and Visualization, Matrix and Array Operations, Loops and Conditionals, Functions and Scripts, Logical & Relational Operations, and File Handling. Each command is accompanied by a brief description of its function. This serves as a quick reference guide for users to efficiently utilize MATLAB's capabilities.

Uploaded by

squad gaming
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Essential MATLAB Commands Guide

This document provides a comprehensive list of important MATLAB commands categorized into sections such as Basic Commands, Math Operations, Plotting and Visualization, Matrix and Array Operations, Loops and Conditionals, Functions and Scripts, Logical & Relational Operations, and File Handling. Each command is accompanied by a brief description of its function. This serves as a quick reference guide for users to efficiently utilize MATLAB's capabilities.

Uploaded by

squad gaming
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Important MATLAB Commands

Basic Commands

clc - Clears the Command Window


clear - Removes all variables from the workspace
close all - Closes all figure windows
who / whos - Lists variables in the workspace
help function_name - Shows help for a specific function
doc function_name - Opens documentation for a function
exit / quit - Closes MATLAB

Math Operations

+, -, *, /, .^, .* - Basic arithmetic operations


sqrt(x) - Square root
log(x) / log10(x) - Natural and base-10 logarithm
exp(x) - Exponential (e^x)
round(x), floor(x), ceil(x) - Rounding functions
mod(x, y) - Modulo (remainder)

Plotting and Visualization

plot(x, y) - 2D line plot


subplot(m,n,p) - Creates subplot in grid
title('text') - Adds title to plot
xlabel('x'), ylabel('y') - Labels axes
legend('name1', 'name2') - Adds legend
grid on/off - Toggles grid
figure - Opens new figure window

Matrix and Array Operations

zeros(n), ones(n) - Create n×n matrix of zeros or ones


eye(n) - Identity matrix
size(A) - Returns size of matrix A
length(A) - Length of vector
A' - Transpose of matrix A
inv(A) - Inverse of A
det(A) - Determinant of A
A .* B - Element-wise multiplication
A*B - Matrix multiplication

Loops and Conditionals


Important MATLAB Commands

for i = 1:n ... end - For loop


while condition ... end - While loop
if ... elseif ... else ... end - Conditional statements
switch ... case ... otherwise ... end - Switch-case statement

Functions and Scripts

function y = myFunc(x) - Define a function


script_name - Run a script file
return - Exit a function early

Logical & Relational Operations

==, ~=, >, <, >=, <= - Relational operators


&&, ||, ~ - Logical AND, OR, NOT
find(A) - Indices of non-zero elements
any(A), all(A) - Tests if any or all elements are true

File Handling

load('[Link]') - Load .mat file


save('[Link]') - Save variables to file
fopen, fclose - Open/close file
fprintf, fscanf - Print to/read from file

You might also like