Buscar

7_Matlab aplicado a Energia comandos tarea1

Prévia do material em texto

MATLAB APLICADO A ENERGÍA
MATLAB APPLIED TO ENERGY
(TERMODINÁMICA)
Freddy Jesús Rojas Chávez
Ingeniero Mecánico, CIP
Magister of Science
Doctoris Philosofiae (e)
• MATLAB - developed by Math Works Inc.
• http://www.mathworks.com
• MATLAB - acronym for MATrix LABoratory
• Matrices and arrays - the heart of MATLAB
• Offers programming features - similar to other languages
• Offers GUI tools
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 2
http://www.mathworks.com/
• Provides extensive numerical resources
• Over 200 reliable, accurate mathematical subprograms
• The subprograms provide solutions to broad range of mathematical 
problems including:
• matrix algebra
• complex arithmetic
• differential equations
• nonlinear systems, and many special functions
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 3
• Available in all operating systems:
•DOS
•Windows9.x/NT
•Unix
•Macintosh
• Same syntax for all platforms
• Open system environment - access to source code
•Allows - to mix MATLAB with FORTRAN or C
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 4
Main screen MATLAB
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 5
Main parts
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 6
Menú
Carpeta de 
trabajo
Archivos 
de la 
carpeta de 
trabajo
System Prompt
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 7
Simple Math
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 8
» 2+2.5+106
ans =
110.5000
» 4*25 + 2^3
ans =
108
» 
Variables in MATLAB
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 9
» D = 2
D =
2
» v = 3
v =
3
Variables in MATLAB
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 10
» rho = 1000;
» mu = 0.001;
» NRe = D*v*rho/mu
NRe =
6000000
» 
Creating function
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 11
Creating function in the ‘script’
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 12
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 13
Used commands
Comandos Descripción
interp1 1-D interpolation (table lookup)
Vq = interp1(X,V,Xq) interpolates to find Vq, the values of the underlying function V=F(X) at the 
query points Xq. X must be a vector of length N.
xlsread xlsread Read Microsoft Excel spreadsheet file.
[NUM,TXT,RAW]=xlsread(FILE,SHEET,RANGE) reads from the specified SHEET and RANGE. 
Specify RANGE using the syntax 'C1:C2', where C1 and C2 are opposing corners of the region. 
Not supported for XLS files in BASIC mode.
importdata importdata Load data from file.
A = importdata(FILENAME) loads data into A.
load load Load data from MAT-file into workspace.
S = load(FILENAME) loads the variables from a MAT-file into a structure array, or data from an 
ASCII file into a double-precision array.
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 14
Used commands
Comandos Descripción
clc Clears the command window and homes the cursor.
clear Clear variables and functions from memory.
clear removes all variables from the workspace.
clear VARIABLES does the same thing.
clear GLOBAL removes all global variables.
clear FUNCTIONS removes all compiled MATLAB and MEX-functions. 
clear ALL removes all variables, globals, functions and MEX links.
disp Display array.
disp(X) displays the array, without printing the array name.
If X is a string, the text is displayed.
plot plot(X,Y) plots vector Y versus vector X.
plot(X,Y,'y-',X,Y,'go') plots the data twice, with a solid yellow line interpolating green circles at 
the data points.
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 15
Used commands
Comandos Descripción
subplot H = subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of 
small axes, selects the p-th axes for the current plot, and returns the axes handle. The axes 
are counted along the top row of the Figure window, then the second row, etc. For example,
subplot(2,1,1), PLOT(income)
subplot(2,1,2), PLOT(outgo)
semilogx semilogx(...) is the same as PLOT(...), except a logarithmic (base 10) scale is used for the X-axis.
legend legend Display legend.
legend(string1,string2,string3, ...) puts a legend on the current plot using the specified 
strings as labels. legend works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You 
can label any solid-colored patch or surface object. The fontsize and fontname for the legend 
strings matches the axes fontsize and fontname.
length length Length of vector.
length(X) returns the length of vector X. It is equivalent to MAX(SIZE(X)) for non-empty 
arrays and 0 for empty ones.
28/03/2016 Freddy J. Rojas Chávez, M.Sc. 16

Continue navegando