<< Chapter < Page Chapter >> Page >
MATLAB accepts log10 for common (base 10) logarithm. To find the log of 10, type in log10(10) and press enter, (ans = 1).

Practice the following examples to familiarize yourself with the common mathematical functions. Be sure to read the relevant help and doc pages for functions that are not self explanatory.

Calculate the following quantities:

  1. 2 3 3 2 1 ,
  2. 5 0.5 1
  3. 4 d 2 for d=2

MATLAB inputs and outputs are as follows:

  1. 2 3 3 2 1 is entered by typing 2^3/(3^2-1) (ans = 1)
  2. 5 0.5 1 is entered by typing sqrt(5)-1 (ans = 1.2361)
  3. 4 d 2 for d=2 is entered by typing pi/4*2^2 (ans = 3.1416)

Calculate the following exponential and logarithmic quantities:

  1. 2
  2. 5 10
  3. 10 5

MATLAB inputs and outputs are as follows:

  1. exp(2) (ans = 7.3891)
  2. log((5^10)) (ans = 16.0944)
  3. log10(10^5) (ans = 5)

Calculate the following trigonometric quantities:

  1. 6
  2. 45
  3. 45

MATLAB inputs and outputs are as follows:

  1. cos(pi/6) (ans = 0.8660)
  2. tan(45*pi/180) (ans = 1.0000)
  3. sin(pi)+cos(45*pi/180) (ans = 0.7071)

The format Function

The format function is used to control how the numeric values are displayed in the Command Window. The short format is set by default and the numerical results are displayed with 4 digits after the decimal point (see the examples above). The long format produces 15 digits after the decimal point.

Calculate θ 3 and display results in short and long formats.

The short format is set by default:

>>theta=tan(pi/3) theta =1.7321>>

And the long format is turned on by typing format long :

>>theta=tan(pi/3) theta =1.7321>>format long>>theta theta =1.732050807568877

Variables

In MATLAB, a named value is called a variable. MATLAB comes with several predefined variables. For example, the name pi refers to the mathematical quantity π, which is approximately pi ans = 3.1416

MATLAB is case-sensitive, which means it distinguishes between upper- and lowercase letters (e.g. data, DATA and DaTa are three different variables). Command and function names are also case-sensitive. Please note that when you use the command-line help, function names are given in upper-case letters (e.g., CLEAR) only to emphasize them. Do not use upper-case letters when running functions and commands.

Declaring variables

Variables in MATLAB are generally represented as matrix quantities. Scalars and vectors are special cases of matrices having size 1x1 (scalar), 1xn (row vector) or nx1 (column vector).

Declaration of a scalar

The term scalar as used in linear algebra refers to a real number. Assignment of scalars in MATLAB is easy, type in the variable name followed by = symbol and a number:

a = 1

Example1
Assignment of a scalar quantity.

Declaration of a row vector

Elements of a row vector are separated with blanks or commas.

Let's type the following at the command prompt:

b = [1 2 3 4 5]

Example2
Assignment of a row vector quantity.

We can also use the New Variable button to assign a row vector. In the tool strip, select Home>New Variable. This action will create a variable called unnamed which is displayed in the workspace. By clicking on the title unnamed, we can rename it to something more descriptive. By double-clicking on the variable, we can open the Variable Editor and type in the values into spreadsheet looking table.

Example_2a1
Using the New Variable button in the tool strip.
Example2a
Assignment of a row vector by using the Variable Editor.

Questions & Answers

where we get a research paper on Nano chemistry....?
Maira Reply
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Google
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, A brief introduction to engineering computation with matlab. OpenStax CNX. Nov 17, 2015 Download for free at http://legacy.cnx.org/content/col11371/1.11
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A brief introduction to engineering computation with matlab' conversation and receive update notifications?

Ask