Matlab
VARIABLES Y FUNCIONES
2.1 VARIABLES
>> Y0=1
Y0 = 1
>>
>> El_nombre_de_esta_variable_tiene_mas_de_sesenta_y_tres_carac
teres_=13
Warning: 'El_nombre_de_esta_variable_tiene_mas_de_sesenta_y_tres_carac
teres_'
exceeds MATLAB's maximum name length of 63 characters and will be truncated to'El_nombre_de_esta_variable_tiene_mas_de_sesenta_y_tres_carac
ter'.
El_nombre_de_esta_variable_tiene_mas_de_sesenta_y_tres_carac
ter =13
>>
>> Z=3+2*j
Z =3.0000 + 2.0000i
>> real(Z)
ans =3
>> imag(Z)
ans =2
2.2 FUNCIONES
>> A=pi*4^2
A =50.2655
>> Perimetro=5*8.6;
>> Area=(Perimetro*7.9)/2
Area =169.8500
>>
2.2.1 VARIABLES SIMBOLICAS
>> a=sym('a');
>>b=sym('b');
>> x=sym('x');
>> f=sym('3*x^3+a*x+b')
f =3*x^3+a*x+b
>>
>> x=sym('x','real');
>> y=sym('y','real');
>>
>> syms x y real
>> z=x+i*y
z = x+i*y
>> conj(z)
ans = x-i*y
>> conj(x)
ans = x
>> z*conj(z)
ans =(x+i*y)*(x-i*y)
>> expand(ans)
ans = x^2+y^2
>>
>> syms x y unreal
>>>> ceil(4.5)
ans =5
>> ceil(-3.7)
ans =-3
>> floor(5.6)
ans =5
>> floor(-8.9)
ans =-9
>> round(7.45)
ans =7
>> round(-7.1)
ans =-7
>>
2.2.2 OPERACIONES CON FUNCIONES
>> syms x
>> f=sym('x^3+2*x')
f = x^3+2*x
>> derivada_f=diff(f)
derivada_f =3*x^2+2
>> pretty(derivada_f)2
3 x + 2
>> integral_f=int(f)
integral_f =1/4*x^4+x^2
>> pretty(integral_f)
4 2
1/4 x + x
>>
2.2.3 GRAFICAS DE FUNCIONES
>> syms x;
>> f=sym('x^3+2*x');
>> ezplot(f)
>>
>> syms x;
>>fplot('sin(x)^2*cos(x)',[0,4*pi])
>>
>> x=[0:0.1:2*pi];
>> plot(x,sin(x))
>>
PARA ESTA GRAFICA DA LO MISMO SI DEFINIMOS EL VECTOR DENTRO DE CORCHETES O DE PARENTESIS, ADEMAS SE DEBE OBSERVAR QUE LA FUNCION A GRAFICAR NO SE DEFINIO SI NO ASTA EN LA INSTRUCCION PLOT.
>> x=(0:0.1:2*pi);
>> y=sin(x);
>> plot(x,y)
>>
>> x=linspace(0,2*pi,70);
>>y=sin(x);
>> plot(x,y)
>>
2.2.4 FUNCIONES INTERNAS DE MATLAB
>> help gradient
GRADIENT Approximate gradient.
[FX,FY] = GRADIENT(F) returns the numerical gradient of the
matrix F. FX corresponds to dF/dx, the differences in the
x (column) direction. FY corresponds to dF/dy, the differences
in the y (row) direction. The spacing between points in eachdirection is assumed to be one. When F is a vector, DF = GRADIENT(F)
is the 1-D gradient.
[FX,FY] = GRADIENT(F,H), where H is a scalar, uses H as the
spacing between points in each direction.
[FX,FY] = GRADIENT(F,HX,HY), when F is 2-D, uses the spacing
specified by HX and HY. HX and HY can either be scalars to specify
the spacing between coordinates orvectors to specify the
coordinates of the points. If HX and HY are vectors, their length
must match the corresponding dimension of F.
[FX,FY,FZ] = GRADIENT(F), when F is a 3-D array, returns the
numerical gradient of F. FZ corresponds to dF/dz, the differences
in the z direction. GRADIENT(F,H), where H is a scalar,
uses H as the spacing between points in eachdirection.
[FX,FY,FZ] = GRADIENT(F,HX,HY,HZ) uses the spacing given by
HX, HY, HZ.
[FX,FY,FZ,...] = GRADIENT(F,...) extends similarly when F is N-D
and must be invoked with N outputs and either 2 or N+1 inputs.
Examples:
[x,y] = meshgrid(-2:.2:2, -2:.2:2);
z = x .* exp(-x.^2 - y.^2);
[px,py] = gradient(z,.2,.2);
contour(z),hold on,...
Regístrate para leer el documento completo.