In this tutorial I will explain to you how to use variables, perform basic arithmetic operations and usage of some common mathematical functions in Matlab. Lets start right away.
Creating a simple variable
Creating a variable is very simple. A variable name, an “=” sign and a value. For example, in command window, you would write,
x = 100
Here, we defined a variable x to have a value of 100.
Basic Arithmetic Operations
Addition, subtraction, multiplication and division is performed by using +, -, *, / operators respectively on a variable. This is shown below:
We are going to give power to variables now. It is simple like:
>> x = 4
Root the numbers back to their squares using:
This is done like:
You do it like a boss:
boss = pi;
There are much more functions to get you started on your work in Matlab. But this is enough for this tutorial as I will slowly be advancing towards more advanced and specialized tutorials in the future.
Do comment if you have questions.