logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Matrixmania Blog
Contact
-> Sitemap <-
Matlab Books
Quick Matlab Guide
Matlab Tutorials
Matlab Examples
Matlab Flow Control
Boolean Algebra
Linear Algebra
Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Matlab Cookbook I
Matlab Cookbook II
Probability and Stats
Forums and Help
Relevant Links
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

Examples: Basic Matlab Codes




Here you can find examples on different types of arithmetic, exponential, trigonometry and complex number operations handled easily with MATLAB codes.


To code this formula: matlab codes 1 fig. , you can write the following instruction in the Matlab command window (or within an m-file):

>> 5^3/(2^4+1)

ans =

    7.3529

>>




To compute this formula: matlab codes 2 fig. , you can always break down the commands and simplify the code (a final value can be achieved in several ways).

>>numerator = 3 * (sqrt(4) - 2)
numerator =

     0

>>denominator = (sqrt(3) + 1)^2
denominator =

    7.4641

>>total = numerator/denominator – 5

total =

    -5

>>



The following expression: matlab codes 3 fig. , can be achieved as follows (assuming that x and y have values already):

>> exp(4) + log10(x) - pi^y



The basic MATLAB trigonometric functions are 'sin', 'cos', 'tan', 'cot', 'sec', and 'csc'. The inverses, are calculated with 'asin', 'atan', etc. The inverse function 'atan2' takes two arguments, y and x, and gives the four-quadrant inverse tangent. Angles are in radians, by default.

The following expression: matlab codes 4 fig. , can be coded as follows (assuming that x has a value already):

>>(sin(pi/2))^2 + tan(3*pi*x).



MATLAB recognizes the letters i and j as the imaginary number. A complex number 4 + 5i may be input as 4+5i or 4+5*i in MATLAB.  The first case is always interpreted as a complex number, whereas the latter case is taken as complex only if i has not been assigned any local value.



Can you verify in MATLAB this equation (Euler's Formula)?
You can do it as an exercise!
Euler's formula
From 'Matlab Codes' to home
From 'Matlab Codes' to 'Matlab Examples'

footer for matlab code page