MATLAB For Engineers Part 2 Display Formats: Short Format Long Format Bank Format Format Short e Format Long e Format Rat
This document discusses various MATLAB display formats such as short format, long format, and bank format. It also covers built-in MATLAB functions like pi, exp, sqrt, log, and trigonometric functions. Additionally, it describes scripts, debugging tools, strings, vectors, matrices, and basic plotting in MATLAB.
MATLAB For Engineers Part 2 Display Formats: Short Format Long Format Bank Format Format Short e Format Long e Format Rat
This document discusses various MATLAB display formats such as short format, long format, and bank format. It also covers built-in MATLAB functions like pi, exp, sqrt, log, and trigonometric functions. Additionally, it describes scripts, debugging tools, strings, vectors, matrices, and basic plotting in MATLAB.
MATLAB for engineers part 2 Display formats short format format that displays only 4 decimal rounding others long format deploys 14 whole digit bank format deploys 2-digit format used for financial calculations format short e exponential notation displays 4 decimals more exponent format long e exponential notation displays 14 decimal places more exponent format rat deploys the rational expression more close that corresponds to the result Manager built-in > > pi PI = 3.1416 > > exp (f) e(exponential) > > sqrt (a) a (square root) > > log (a) log (natural logarithm) > > log10 (a) log10to (base 10 logarithm) Note: In the case of negative logarithms MATLAB returns it as a complex number Trigonometric functions Inverse function > > without (a) > > asin (a) > > cos (b) > > acos (b) > > as (c) > > bind (c)
Scripts Scripts: Collection of executed commands written in matlab with extension *.m saved as MATLAB files editor.
[Seleccione la fecha] 5 [Escriba el ttulo del documento]
Debugging tolos: Runs the step by step program and locate mistakes (logical errors). Real time error check: Czech syntax is correct Green good syntax Orange (Warning) run the program Red (Error) do not run the program White (indefinite) while we are typing Reviews: In MATLAB is recommended to add comments that will help us to put a comment without affecting the execution only must prepend the "%" sign String: String Arrangements Matrix of numbers (double or complex) Arrays of objects (data structure more advanced) Vector line: values are enclosed in brackets and are separaso by fields or comma > > row = [2-1 - 3.4 5.6]; = row = [1, 2, - 3.4, 5.6]; row = 1 2 - 3.4 5.6
[Seleccione la fecha] 6 [Escriba el ttulo del documento] Vector column: values in brackets and separated by a comma > > column = [9; 8 - 7.4; 5.4]; column = 9 8 -7.4 5.4 Differences between vector line and column vector 1. Looking within the Workspace 2. Deploying the variable in the command window 3. Using the function size) > > size (row) 1 4 1 line x 4 columns > > size (column) 4 1 4 line x 1 columns
Length: length of a vector length) > > length (row) > > length (column) 4 4 Are 4 elements which composed this vector
Matrices There are two ways to create arrays 1. Element by element > > A = [1, 2, 3 4] 2. Concateneando vectors or matrices > > a = [2-1]; b = [4-3]; c = [5, 6]; > > d = [a; b]; >>E= [D c ];
>> Str= [Hello, I am MATLAB]; Plot (Grafica Simple) Funcion Plot: Genera puntos en cada par (x, y) para despus conectar dichos puntos con una linea Funcion linspace: crea un vector con elemetnos uniformemente espaciados
[Seleccione la fecha] 7 [Escriba el ttulo del documento] >> x=linspace (0 , 4*pi , 1000); >>plot(y) Grafica los valores de y contra sus indices >>plot (x , y) Grafica los valores de x contra los valores de y Nota: si se desea hacer que una funcin luzca mas suave es necesario evaluar mas puntos Ejemplo: >> x=linspace (0 , 4*pi , 1000); >> plot (x, sin(x)); %% Se estn anidando funciones
Nota: Los vectores x y y deben ser del mismo tamao de lo contrario obtendremos un error >> plot ([1 2], [1 2 3]); ??? Error using ==> plot Vectors must be the same lengths.