(MATLAB) How does a command or function work? >> help sqrt SQRT Square root SQRT(X) is the square root of the elements of X Complex results are
Previous PDF | Next PDF |
[PDF] Lectures on Matlab
Most of the usual mathematical functions are implemented in MATLAB >> cos(0) Write a script file to calculate the squares of the integers up to 20 A script
[PDF] Notes introductives à Matlab
On peut utiliser Matlab, soit en mode en ligne, c'est-à-dire saisir des commandes dans la fenêtre d' Matrix functions - numerical linear algebra Square root
[PDF] Initiation au logiciel Matlab
3 PROGRAMMATION ET M-FILE FUNCTIONS axis('square') présente le graphe dans un carré au lieu du rectangle habituel 7 4 Les commandes figure, hold
[PDF] MATLAB tutorial - Faculty Washington
(MATLAB) How does a command or function work? >> help sqrt SQRT Square root SQRT(X) is the square root of the elements of X Complex results are
[PDF] Getting Started with MATLAB
square is (n3 + n)/2 The magic Function MATLAB actually has a built-in function that creates magic squares of almost any size Not surprisingly, this function is
[PDF] MATLAB® Primer
MATLAB and Simulink are registered trademarks of The MathWorks, Inc See MATLAB actually has a built-in function that creates magic squares of almost any
[PDF] MATLAB Tutorial
DOC: DOC FUN displays the help browser for the MATLAB function FUN (e g doc help) You can invoke matrix is defined inside a pair of square brackets ([])
[PDF] Short Matlab Manual
To use this function to calculate the area and circumference of a rectangle with sides 5 and 7, and for a square with side 6, we type the following at the Matlab
[PDF] MATLAB Programming
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, and xPC To create a 5-by-5 magic square matrix, use the magic function as shown eye
[PDF] Matlab Guide - Cleveland State University
15 sept 2008 · tary math functions are in matlab\elfun, so I type help matlab\elfun than or equal to 100 that have integer square roots It shows you how to
[PDF] fundamentals of corporate finance pdf
[PDF] fundamentos de administracion y gestion
[PDF] fundamentos de gestión empresarial
[PDF] fundamentos de gestion empresarial definicion
[PDF] fundamentos de gestion empresarial enfoque basado en competencias pdf
[PDF] fundamentos de gestion empresarial enfoque basado en competencias pdf gratis
[PDF] fundamentos de gestion empresarial julio garcia del junco pdf
[PDF] fundamentos de gestion empresarial libro
[PDF] fundamentos de gestion empresarial mc graw hill pdf
[PDF] fundamentos de gestión empresarial pearson pdf
[PDF] fundamentos de gestion empresarial unidad 1
[PDF] fundamentos de marketing kotler 13 edicion pdf
[PDF] fundamentos de marketing kotler 14 edicion pdf
[PDF] fundamentos de marketing kotler 8va edicion pdf
Introduction to MATLAB
Very sophisticated "graphing calculator"
High-level programming language for sci-
entific computingSimilar to PYTHON, with more built-in BUT
not open-source vs. c or FORTRAN, many built-in com- mands, less-complex syntax vs. c or FORTRAN, Interpreted language (code translated during run), with some pre- compiled functionsIF used carefully, good balance of speed
and ease of useOur introduction follows, in part, section 1
of the excellent "An introduction to Matlab for dynamic modeling" by Guckenheimer and Ell- ner: www.cam.cornell.edu/ dmb/DMBsupplements.html, as well as mate- rial from Prof. Mark Goldman, UC DavisLaunch matlab!Command window (graphing calculator) mode
>> 1+3 ans = 4Assigningvaluestovariables
>> a=1+3 a = 4Displaying values
>> a a = 4Suppressing display of output in MATLAB
>> a=1+3; 1BASIC OPERATIONS:
Arithmetic
/ (divide) (multiply)ˆ (exponent)
abs(x) (absolute value) cos(x), sin(x), tan(x) exp(x) exponential function eˆx log(x) log to base e sqrt(x) square rootThe latter are built-in functions
>> a = sqrt(5) a = 1.4142 >> a=2 ; b=4 ; c=aˆb c = 16There are also some built-in variables >> pi ans = 3.1416 >> cos(pi) ans = -1 2FUNDAMENTAL PROGRAMMING SYNTAX:
LHS = RHS
value RHS assigned to LHS, NOT other way around >> c=2 c = 2 >> 2=c ??? 2=c Error: The expression to the left of the equals sign is not a valid target for an assignment.Another example:
>> a=2;b=4; >> a=b; >> a,b a = 4 b = 4 >> a=2;b=4; >> b=a; >> a,b a = 2 b = 2 3Variable names:
>> a1=2 >> my_favorite_variable_number_2=4VALID: Letter followed by letters, numbers, un-
derscore character.NOTE! capitalization matters.A6=a!!
NOT VALID:
>> my_favorite_variable#2=4 ??? my_favorite_variable#2=1 >> 2a=1Error: Unexpected MATLAB expression.
And using periods gives a different, more
advanced type of variable (data structure) that we won"t discuss now >> my.favorite.variable.name=1 my = favorite: [1x1 struct]ORDER OF OPERATIONS:PEMDAS
parenthesis exponentiation multiplication division addition subtractionSay we want:a= 2; b= 4; c=aa+b
>> a=1 ; b=4 ; c=a/a+b c = 5 >> a=1 ; b=4 ; c=a/(a+b) c = 0.2000 !! When in doubt, put lots of parentheses !! 4CHECK: What do you get for the below, and why?
>> a=1 ; b=4 ; c =0 ; >> d=a/0+b >> d=a/(0+b) >> d=-aˆ2 >> d=(-a)ˆ2 5Check: what variables stored in memory:
whoscommand (MATLAB) >> whosName Size Bytes Class Attributes
a 1x1 8 double b 1x1 8 double c 1x1 8 double OR look in "workspace" to see variables and valuesOR just type variable at command line
>> a a = 1 GOOD PRACTICE: clear variables before starting to program (MATLAB:) >> clear all >> whosCommands stored in memory:
See command history, or just hit "up arrow"
6 Representation of numbers in scientific computing: finite precisionStandard: IEEE floating point arithmetic.
Important feature - finite precision: approx 16 significant digitsDisplay more digits:
>> a=0.1 a =0.1000
>> format long >> a a = 0.100000000000000Roundoff error:
>> a=4/3 ; b=a-1 ; c = (3 *b)-1 c = -2.220446049250313e-16 7OVERFLOW AND UNDERFLOW:
Maximum number:10308
Minimum number:10308
Overflow:
>> a=10ˆ400 a = InfUnderflow
>> a=10ˆ-400 a = 0Another special number: not defined
>> 0/0 ans = NaN 8HELP !! (MATLAB)
How does a command or function work?
>> help sqrtSQRT Square root.
SQRT(X) is the square root of the elements of X. Complex results are produced if X is not positive.See also sqrtm, realsqrt, hypot.
Reference page in Help browser
doc sqrt >> doc sqrt Thanks anyway, but what SHOULD I be looking up? the lookfor command >> lookfor exponentEXP Exponential.
EXPINT Exponential integral function.
EXPM Matrix exponential.
HELP !!: Remember Google and stackoverflow, etc are your friends 9VECTORS
A vector value is just a list of scalar values.
Arranged horizontally into arow vector:
~x= (6 12 5):(1)Or vertically into acolumn vector:
~x=0 @6 12 51A :(2)
In MATLAB, row vector:
>>x=[6 12 5] x = 6 12 5 OR >>x=[6 ,12 ,5] x = 6 12 5 10In MATLAB, column vector:
>>x=[6 ; 12 ; 5] x = 6 12 5 Thetransposeoperation switches between row and column vectors. This is given by dot prime in MATLAB. That is, in MATLAB: >> y=x." 11Easy way to make (row) vectors [MATLAB, ]
x = start : increment : end >> x=0:1:10 x =0 1 2 3 4 5 6 7 8 9 10
>> x=1:.1:1.5 [MATLAB] x =1.0000 1.1000 1.2000 1.3000 1.4000 1.5000
Accessing vector elements (or components):
MATLAB:
>> x5=x(5) x5 = 1.4000 >> x(7) ??? Index exceeds matrix dimensions.Indexing starts with 1; x(0) does not work.
12Exercise 0.1: Have MATLAB compute the values of
1. Mak ea list n umbersspaced b y0.2, betw eena minim umv alueof 1 and a maxim umv alue of 20. Assign that list to the variable namemyvector. 2. use help to look up the linspacecommand, and repeat the previous command using linspace 3. pic kout the 4th v alueof myvectorand assign it to the variable namefourthelement 13TWO BASIC OPERATIONS ON VECTORS:
Multiplication by scalar
c~x=0 @x 1 x 2 x 31A =0 @cx 1 cx 2 cx 31
A ; that is,xj!cxj