ProgrammingMatlab_2.pdf

(2456 KB) Pobierz
732401803 UNPDF
M ATH F UNCTION
M - FILE
S COPE OF V AR .
D ATA I/O
G ENERALIZED V ARIABLES
Applications
MATLAB Tutorial – Programming in MatLab
Chienmin Chuang
School of Mathematics, University of Birmingham
November 24, 2011
by C. Chuang
732401803.017.png 732401803.018.png 732401803.019.png
M ATH F UNCTION
M - FILE
S COPE OF V AR .
D ATA I/O
G ENERALIZED V ARIABLES
Applications
I NLINE FUNCTION
A handy way to define a simple function is using
FunctionName = inline(’Expression’,’var1’,’var2’,...,’varN’)
which reads VarN,...,Var1 as inputs and returns an output by
Expression.
Example:
by C. Chuang
732401803.020.png 732401803.001.png 732401803.002.png 732401803.003.png
M ATH F UNCTION
M - FILE
S COPE OF V AR .
D ATA I/O
G ENERALIZED V ARIABLES
Applications
I NLINE FUNCTION
A handy way to define a simple function is using
FunctionName = inline(’Expression’,’var1’,’var2’,...,’varN’)
which reads VarN,...,Var1 as inputs and returns an output by
Expression.
Example:
1. f=inline(’3*x:^2+2*y+z’,’x’,’y’,’z’), f(1,2,3) Enter
by C. Chuang
732401803.004.png 732401803.005.png 732401803.006.png 732401803.007.png 732401803.008.png
M ATH F UNCTION
M - FILE
S COPE OF V AR .
D ATA I/O
G ENERALIZED V ARIABLES
Applications
I NLINE FUNCTION
A handy way to define a simple function is using
FunctionName = inline(’Expression’,’var1’,’var2’,...,’varN’)
which reads VarN,...,Var1 as inputs and returns an output by
Expression.
Example:
1. f=inline(’3*x:^2+2*y+z’,’x’,’y’,’z’), f(1,2,3) Enter
2. g=inline(’5*sin(w)+6*cos(u)’,’w’,’u’), g(4,5) Enter
by C. Chuang
732401803.009.png 732401803.010.png 732401803.011.png 732401803.012.png
M ATH F UNCTION
M - FILE
S COPE OF V AR .
D ATA I/O
G ENERALIZED V ARIABLES
Applications
I NLINE FUNCTION
A handy way to define a simple function is using
FunctionName = inline(’Expression’,’var1’,’var2’,...,’varN’)
which reads VarN,...,Var1 as inputs and returns an output by
Expression.
Example:
1. f=inline(’3*x:^2+2*y+z’,’x’,’y’,’z’), f(1,2,3) Enter
2. g=inline(’5*sin(w)+6*cos(u)’,’w’,’u’), g(4,5) Enter
3. whos f g Enter
by C. Chuang
732401803.013.png 732401803.014.png 732401803.015.png 732401803.016.png
Zgłoś jeśli naruszono regulamin