Jump to content

MATLAB Programming/Fundamentals of MATLAB/Basic MATLAB commands

From Wikibooks, open books for an open world

Basic MATLAB command

[edit | edit source]
Matlab Logo which is produced by the 3D surface plot
Matlab Logo which is produced by the 3D surface plot

During start to use the program, you may see "double greater than" symbols aka >> on the top left of command window.
You can start to type simple or complex mathematic equation to your liking.

Some of the examples are as follows:

>> 6+3 - 4/2

ans =
     7

>> sind(30)

ans =
    0.5000

or you may even assign a value to a variable / perform simple algebra equations

>> x = 200 % assigning value 200 to variable x

x =
   200

>> y = 120 % assigning value 120 to variable y

y =
   120

>> p = x-y % make a simple subtraction equation where the x is subtract y equals to p

p =
    80

Note: You can learn more about MATLAB operator from this page: MATLAB Programming/Fundamentals of MATLAB/MATLAB operator

Basic Commands

[edit | edit source]

These commands listed below are the commands that you usually will encounter when using MATLAB

clc - Clear command window.
clear - Remove all variable values from workspace
disp - Display the values inside of the variable / matrix
help - Display tooltip help text inside the Command Window. The help displays the help for the functionality specified by NAME, such as a function, operator symbol, method, class, or toolbox.

Hello World

[edit | edit source]

Once Hello World, which is the simplest of programs, works the beginner can move on to explore the MATLAB workspace available for developing or running Matlab code.

Using the workspace the beginner can then learn to manipulate basic MATLAB Variables.

For convenience Matlab allows the workspace to be saved and loaded using *.mat files.