Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
MATLAB
Ingeboude Matlab funksies/ Built-in Matlab functions:
Hieronder volg ’n paar van die belangrikste Matlabfunksies wat in hierdie kursus gebruik
gaan word:/ A few of the Matlab functions we will be using in this course:
format long
input
min
spline
eig
format short hold on
sum
interp1
triu
format rat
hold off
prod
trapz
tril
format bank
figure
mean
polyfit
contourf
linspace
axis square max
polyval
contour3
logspace
text
clc
quad
flipud
length
gtext
clear
quadl
fliplr
plot
input
clf
ode23
factorial
plot3
ginput
size
ode45
who
title
eye
disp
diag
whos
grid
ones
fprintf
meshgrid
xlabel
zeros
fzero
mesh
ylabel
rand
roots
surf
subplot
sort
inv
surfl
axis
break
det
contour
fplot
return
cond
det
Voorbeelde/Examples:
format long bv./e.g. y = 2.54901960784314 ; format short bv./e.g. y = 2.5490
format rat bv./e.g. y = 130/51 ; format bank bv./e.g. y = 2.55
rats(3.141516) = 1731/551
linspace(-5,5)
length(x); size(A)
plot(x,y),grid,hold on, plot(x,z),hold off
title('Grafiek van y = sin(x)*exp(-x) -1')
xlabel('Temperatuur'); ylabel('Druk')
plot(x,y),figure(2), plot(x,z)
subplot(2,3,1)
axis([-4 4 -1 10])
fplot('sin(x.^3)',[-5 5])
text(5,4,'Snypunt'); gtext('Snypunt')
n = input('Waarde van n: ')
[x,y] = ginput of/or [x,y] = ginput(n)
eye(3); eye(4,2); ones(4); ones(5,4);
zeros(3); zeros(4,6); rand(4); rand(1,10)
sort([7 -2 4 3 -1]) = -2 -1 3 4 7
max([22 3 -5 72] = 72; min([22 3 -5 72]) = -5
sum([2 6 1 -3]) = 6; prod([2 6 1 -3]) = -36
mean([5 4 6 3 2]) = 4
clc: Clear command window
clear : Verwyder alle veranderlikes uit die werkarea ("workspace").
Removes all variables from the workspace.
clear x z p : Verwyder slegs hierdie veranderlikes uit die werkarea.
Removes these variables from the workspace.
clf: Clear figure.
disp(x); disp(' A
B
C')
fprintf('The answer is : %8.4f\n',x)
fzero('x.^3-5*x+1',1); roots([1 2 -3])
inv(A); det(A); cond(A)
polyfit(x,y,3); polyval(p,2.7)
spline(x,y,xx); interp1(x,y,xx)
trapz(x,y); quad('x.^3-5*x+1',0,1)
[t,y] = ode23('funk1',[0 20], [1 -1])
[x y] = meshgrid(-2:0.2:2, -5:0.5:5)
z = sin(x.*y).^2 – exp(x-y);
mesh(x,y,z), surf(x,y,z), contour(x,y,z), surfl(x,y,z),
mesh(z), surf(z), ens./etc.
eig(A): Eiewaardes van matriks A./ Eigenvalues of matrix A.
triu(A): Bo-driehoekvorm van matriks A./ Upper- triangular form of matrix A.
tril(A): Onder-driehoekvorm van matriks A./ Lower-triang. form of matrix A.
flipud(A):(Flip up-down) Ruil rye van matriks A om. / Exchanges rows of matrix A.
fliplr(A):(Flip left-right) Ruil kolomme van matriks A om./Exchanges columns of A.
diag(A): Diagonaal van matriks A./ Diagonal of matrix A.
diag(v): Plaas die vektor v op die diagonaal van 'n nul-matriks./Places vector v on the
diagonal of a zero matrix.
contourf: Filled contour plot.
contour3: 3D contour plot.
Wiskundige funksies in Matlab / Mathematical functions in Matlab:
(Ken almal behalwe dié wat in hakies is / Know all except those in brackets)
>> help elfun
Elementary math functions.
Trigonometric.
sin
- Sine.
sind
- Sine of argument in degrees.
sinh
- Hyperbolic sine.
asin
- Inverse sine.
asind
- Inverse sine, result in degrees.
asinh
- Inverse hyperbolic sine.
cos
- Cosine.
cosd
- Cosine of argument in degrees.
cosh
- Hyperbolic cosine.
acos
- Inverse cosine.
acosd - Inverse cosine, result in degrees.
acosh - Inverse hyperbolic cosine.
tan
- Tangent.
tand
- Tangent of argument in degrees.
tanh
- Hyperbolic tangent.
atan
- Inverse tangent.
atand - Inverse tangent, result in degrees.
(atan2 - Four quadrant inverse tangent).
atanh - Inverse hyperbolic tangent.
sec
- Secant.
secd
- Secant of argument in degrees.
sech
- Hyperbolic secant.
asec
- Inverse secant.
asecd - Inverse secant, result in degrees.
asech - Inverse hyperbolic secant.
csc
- Cosecant.
cscd
- Cosecant of argument in degrees.
csch
- Hyperbolic cosecant.
acsc
- Inverse cosecant.
acscd - Inverse cosecant, result in degrees.
acsch - Inverse hyperbolic cosecant.
cot
- Cotangent.
cotd
- Cotangent of argument in degrees.
coth
- Hyperbolic cotangent.
acot
- Inverse cotangent.
acotd - Inverse cotangent, result in degrees.
acoth - Inverse hyperbolic cotangent.
Exponential.
exp
- Exponential.
(expm1 - Compute exp(x)-1 accurately).
log
- Natural logarithm.
(log1p - Compute log(1+x) accurately).
log10 - Common (base 10) logarithm.
(log2
- Base 2 logarithm and dissect floating point number).
(pow2 - Base 2 power and scale floating point number).
(realpow - Power that will error out on complex result).
(reallog - Natural logarithm of real number).
(realsqrt - Square root of number greater than or equal to zero).
sqrt
- Square root.
nthroot - Real n-th root of real numbers.
(nextpow2 - Next higher power of 2).
Complex.
abs
- Absolute value.
(angle
- Phase angle).
(complex - Construct complex data from real and imaginary parts).
(conj
- Complex conjugate).
(imag
- Complex imaginary part).
(real
- Complex real part).
(unwrap - Unwrap phase angle).
(isreal
- True for real array).
(cplxpair - Sort numbers into complex conjugate pairs).
Rounding and remainder.
fix
- Round towards zero.
floor - Round towards minus infinity.
ceil
- Round towards plus infinity.
round - Round towards nearest integer.
(mod - Modulus (signed remainder after division)).
rem
- Remainder after division.
sign - Signum.