Matlab Manual
Matlab Manual
LABORATORY MANUAL
FOR
MATLAB: MATHEMATICS-I for ENGINEERS
Coordinators:
&
Table of Contents
1 Laboratory - 0
3
MATLAB FUNDAMENTALS
2 Laboratory - 1
8
CARTESIAN AND POLAR PLOTS
3 Laboratory - 2
4 Laboratory – 3
27
PARTIAL DERIVATIVES AND JACOBIAN
5 Laboratory - 4
36
FINDING EXTREME VALUES FOR A FUNCTION OF TWO VARIABLES
6 Laboratory - 5
44
CONSISTENCY OF SYSTEM OF LINEAR EQUATIONS
7 Laboratory – 6
8 Laboratory – 7
52
EIGNE VALUE AND EIGEN VECTOR
9 Laboratory – 8
10 Laboratory – 9
60
EUCLID'S ALGORITHM
11 Laboratory – 10
62
BETA AND GAMMA FUNCTIONS
Laboratory - 0
MATLAB FUNDAMENTALS
Matlab is a high performance language for technical computing. Matlab is an interactive system
whose data element is an array that does not require dimensioning.
Matlab features a family of application specific solution called toolboxes. Toolboxes allow us to learn
and apply specialized technology. Toolboxes are comprehensive collection of Matlab functions (M
files) that extend the Mablab environment to solve particular class of problems. Areas in which toll
boxes are available include Fuzzy logic, Neural Networks, Signal Processing, Control Systems,
Wavelets, Simulation and many more.
Assignment:
Exercise:
Library functions
clc – clear the screen
clear – clear all the variables used so far in the command window
help NAME - Display help text in Command Window
(If NAME is not specified, help displays content relevant to your previous actions.)
sqrt(),
sin(), cos(), tan(), : Trigonometric functions in radians
sind(), cosd(), tand(), : Trigonometric functions in degrees
exp(), sinh(), cosh(), : Exponential or hypergeometric functions
log(), log10(), log2(), : Logarithmic functions
asin(), acos(), atan() : Inverse Trigonometric functions
B=[1; 2; 3; 4; 5; 6]
or
B=[1
2
3 a column matrix
4
5
6]
Syntax
<variable name> = a : n : b
where a is the initial value, n is the increment/decrement (default is 1), b is the final value
Example:
1) X=1:10
X=
1 2 3 4 5 6 7 8 9 10
2) Y=10:-1:1
Y=
10 9 8 7 6 5 4 3 2 1
3) Z=3.5:0.25:5.75
Z=
3.5000 3.7500 4.0000 4.2500 4.5000 4.7500 5.0000 5.2500 5.5000 5.7500
4) Z=3.5:0.25:5.7
Z=
3.5000 3.7500 4.0000 4.2500 4.5000 4.7500 5.0000 5.2500 5.5000
linspace
linspace Linearly spaced vector.
Syntax
linspace(X1, X2)
generates a row vector of 100 linearly equally spaced points between X1 & X2.
linspace(X1, X2, N)
generates N points between X1 and X2.
Note: for N = 1, linspace returns X2.
Examples:
Generate vectors X,Y,Z using linspace command
X=1:10 linspace(1,10,10)
Y=10:-1:1 linspace(10,1,10)
Z=3.5:0.25:5.75 linspace(3.5,5.75,10)
Matrix Operations:
Operator Function Command
+ Addition A+B
- Subtraction A-B
* Multiplication A*B
/ Division A/B (computes A*B-1 )
.* Element by element multiplication A.*B
./ Element by element division A./B
inv Inverse of a non-singular matrix inv(A)
Logical operators
Symbol Meaning
== Equal
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
~= Not equal to
Laboratory Exercises
3) Create two matrices A and B of same size and perform the above operations.
Laboratory - 1
Aim: To plot standard Cartesian curves in xy-plane (2D plots) and polar curves in r-plane.
fplot(FUN) plots the function FUN between the limits of the current axes, with a default of [-5 5].
fplot(FUN,LIMS)
fimplicit(FUN) plots the curves where FUN(X,Y)==0 between the axes limits,
with a default range of [-5 5].
fimplicit(FUN,LIMS) uses the given limits. LIMS can be [XMIN XMAX YMIN YMAX]
syms x y
m=2;
c=1;
fimplicit(y == m*x + c)
syms x y
fimplicit(x^2 + y^2 == 1)
hold on
fimplicit(x^2 + y^2 == 4,'r')
hold off
syms x y
a=[1 2 3 4 5];
fimplicit(y^2 - 4*a*x == 0,[-20,20])
hold on
fimplicit(x^2 - 4*a*y == 0,[-20,20])
hold off
syms x y
for a=[4 6 8];
b=2;
fimplicit((x/a)^2 + (y/b)^2 == 1,[-a,a])
hold on
end
hold off
syms x y
for b=[1 2 3];
a=2;
fimplicit((x/a)^2 - (y/b)^2 == 1)
hold on
end
hold off
th=0:0.01:2*pi;
a=2;
r=a*(1+cos(th));
polarplot(th,r)
title('Cardiod')
th=0:0.01:2*pi;
a=2;
r=cos(2*th);
polarplot(th,r)
title('4 Leaved Rose')
plotedit off
th=0:0.01:2*pi;
a=2;
r=a*(1+cos(th));
polarplot(th,r)
hold on
r=a*(1-cos(th));
polarplot(th,r)
hold off
syms x y
for c=[1 2 3];
fimplicit(x*y == c)
hold on
end
hold off
Assignment:
1) Plot a parabola and a straight line in xy-plane. Locate the points of intersection.
2) Draw a 6-leaved rose.
Assignment:
1) Plot a parabola and a straight line in xy-plane. Locate the points of intersection.
Cannot be plotted.
Laboratory - 2
Formulae:
1) Angle between two polar curves=
S = solve(eqn1,eqn2,...,eqnM,var1,var2,...,varN)
1. Find the angle between two polar curves and . Hence show
graphically the point of intersection.
syms r1 th r2 a
r1=a*(1-sin(th));
ph1=r1/diff(r1);
r2=a*(1+sin(th));
ph2=r2/diff(r2);
it=solve(r1-r2==0,th);
% simplify(ph1*ph2) % to show product of slope as -1
Ang=abs(atan(ph1)-atan(ph2));
subs(Ang,it)
ans =
clear
a=1;
t=0:0.1:2*pi;
r1=a*(1-sin(t));
polarplot(t,r1)
hold on
r2=a*(1+sin(t));
polarplot(t,r2)
hold off
clear
syms r1 th r2 a
r1=a*exp(th);
ph1=r1/diff(r1);
r2=a*exp(-th);
ph2=r2/diff(r2);
it=solve(r1-r2==0,th);
Ang=abs(atan(ph1)-atan(ph2));
subs(Ang,it)
ans =
Plotting exercise
clear
a=1;b=1;
t=-pi:0.1:pi;
r1=a*exp(-t);
polarplot(t,r1)
hold on
r2=b*exp(-t);
polarplot(t,r2)
hold off
syms r1 th r2
r1=3*cos(th);
ph1=r1/diff(r1);
r2=1+cos(th);
ph2=r2/diff(r2);
it=solve(r1-r2==0,th);
Ang=abs(atan(ph1)-atan(ph2));
subs(Ang,it)
ans =
Plotting exercise
clear
syms r1 th r2
th=0:0.1:2*pi;
r1=3*cos(th);
polarplot(th,r1);
hold on
r2=1+cos(th);
polarplot(th,r2);
hold off
clear
syms x y
y=4*sin(x)-sin(2*x);
d1=diff(y,1);
d2=diff(y,2);
rc=(1+d1^2)^(3/2)/d2;
rcv=abs(subs(rc,{x},{pi/2}))
rcv =
clear
syms x y a b c
y=a*x^2+b*x+c;
d1=diff(y,1);
d2=diff(y,2);
rc=(1+d1^2)^(3/2)/d2;
rcv=subs(rc,{x},{(sqrt(a^2-1)-b)/(2*a)})
rcv =
clear
syms x y a
y=a*cosh(x/a);
d1=diff(y,1);
d2=diff(y,2);
rc=(1+d1^2)^(3/2)/d2;
rcv=subs(rc,{x},{a})
rcv =
vpa(rcv)
ans =
clear
syms x y a
y=x^3*(x-a);
d1=diff(y,1);
d2=diff(y,2);
rc=(1+d1^2)^(3/2)/d2;
rcv=subs(rc,{x},{a})
rcv =
8. Show that radius of curvature for varies as using polar form of the formula.
clear
syms r th a
r=a*(1-cos(th));
r1=diff(r,th);
r2=diff(r,th,2);
rc=(r^2+r1^2)^(3/2)/(r^2+2*r1^2-r*r2)
ans =
Assignment:
Laboratory - 3
Formulae:
f
1) Differentiate f w.r.t x by treating all other independent variables as constant
x
𝜕𝑢 𝜕𝑢
𝜕(𝑢,𝑣) 𝜕𝑥
2) Jacobian of (u,v) w.r.t (x,y) is 𝐽 = =[ 𝜕𝑦
]
𝜕(𝑥,𝑦) 𝜕𝑣 𝜕𝑣
𝜕𝑥 𝜕𝑦
2 f 2 f
Note : 1) and are called mixed derivatives and are equal.
xy yx
2) Jacobian is a consequence of geometric distortion due to transformation
If expr is a symbolic vector or matrix, this function simplifies each element of expr
if expression
statements
ELSEIF expression
statements
ELSE
statements
END
fimplicit3(FUN) plots the surface where FUN(X,Y,Z)==0 between the axes limits,
with a default range of [-5 5].
jacobian(f,x) computes the Jacobian of the scalar or vector f with respect to the vector x.
Activities
1. Find all possible partial derivatives up to second order for the function f(x,y)=xy
2. Find all possible partial derivatives up to second order for f(x,y,z)=xyz
3. If then show that .
Assignment
Compute the Jacobian using built-in function and vice versa for the problem Nos.7 to 10.
Find all possible partial derivatives up to second order for the function f(x,y)=xy
clear
syms x y f
f=x*y
dfx=diff(f)
dfy=diff(f,y)
dfxx=diff(f,2) % dfxx=diff(diff(f),x)
dfxy=diff(dfx,y)
dfyx=diff(dfy,x)
dfyy=diff(dfy,y)
clear
syms x y z f(x,y,z)
f=x*y*z
dfx=diff(f)
dfy=diff(f,y)
dfz=diff(f,z)
dfxx=diff(f,2) % dfxx=diff(diff(f),x)
dfxy=diff(dfx,y)
dfxz=diff(dfx,z)
dfyx=diff(dfy,x)
dfyy=diff(dfy,y)
dfyz=diff(dfy,z)
dfzx=diff(dfz,x)
dfzy=diff(dfz,y)
dfzz=diff(dfz,z)
clear
syms x y u
u=x^2*atan(y/x)-y^2*atan(x/y)
dux=diff(u);
dfxyL=diff(dux,y);
dfxy=simplify(dfxyL)
u =
dfxy =
clear
syms x y u
u=x^y
dux=diff(u);
dfxy=diff(dux,y);
dfxyL=simplify(dfxy)
duy=diff(u,y);
dfyx=diff(duy,x);
dfxyR=simplify(dfyx)
if (dfxyL==dfxyR)
disp('Mixed Derivatives are Equal')
end
u =
dfxyL = dfxyR =
clear
syms x y z u
u=log(tan(x)+tan(y)+tan(z))
ux=diff(u,x)
uy=diff(u,y)
uz=diff(u,z)
LHS=sin(2*x)*ux+sin(2*y)*uy+sin(2*z)*uz
simplify(LHS)
u =
ux = uy = uz =
LHS =
ans =2
clear
syms x y Z
Z=(x^2+y^2)/(x+y)
ux=diff(Z)
uy=diff(Z,y)
LHS=(ux-uy)^2
RHS=4*(1-ux-uy)
LHS1=simplify(LHS)
RHS1=simplify(RHS)
if (LHS1==RHS1)
disp('Given relation is true')
end
Z =
ux = uy =
LHS = RHS =
LHS1 = RHS1 =
syms x y r th
x=r*cos(th);
y=r*sin(th);
J=[diff(x,r) diff(x,th);diff(y,r) diff(y,th)];
J1=simplify(det(J));
fimplicit3(x)
fimplicit3(y)
fimplicit3(J)
J1 = r
clear
syms x y u v
u=x*sin(y);
v=y*sin(x);
J=[diff(u,x) diff(u,y);diff(v,x) diff(v,y)];
J1=simplify(det(J))
fimplicit3(x)
fimplicit3(y)
fimplicit3(J)
J1 =
clear
syms x y u v
x=u^2-v^2;
y=2*u*v;
J=[diff(x,u) diff(x,v);diff(y,u) diff(y,v)];
J1=simplify(det(J))
fimplicit3(x)
fimplicit3(y)
fimplicit3(J)
J1 =
clear
syms x y z u v w
u=5*y;
v=4*x^2-2*sin(y*z);
w=y*z;
fimplicit3(u)
fimplicit3(v)
fimplicit3(w)
J=jacobian([u;v;w],[x y z])
fimplicit3(J)
J =
Laboratory - 4
Aim: To find the extreme values of the function of two variables i.e. to find the maximum or
minimum value of the function f(x,y).
vpasolve([eq1,...,eqn],[x1,...,xm])
FUN is plotted over the axes size, with a default interval of -5 < X < 5, -5 < Y < 5.
fprintf(FORMAT, A, ...) formats data and displays the results on the screen.
Activities
clear
syms x y
f=x^3+y^3-3*x-12*y+20
fx = diff(f,x);
fy = diff(f,y);
S = vpasolve([fx==0, fy==0],[x y]);
ml = [S.x S.y];
sf=fsurf(f);
xsy=size(ml);
ed=xsy(:,1);
for i=1:ed
fprintf('Critical Points are ( %d, %d ) \n',ml(i,:))
end
for i=1:ed
A=diff(fx,x);
AV=subs(A,{x y},{ml(i,:)});
B=diff(fx,y);
C=diff(fy,y);
Con=A*C-B^2;
ConV=subs(Con,{x y},{ml(i,:)});
fV=subs(f,{x y},{ml(i,:)});
if (ConV>0 & AV<0)
fprintf('Maximum at ( %d, %d ) and Max. Value= %d \n',ml(i,:),fV)
elseif (ConV>0 & AV>0)
fprintf('Minimum at ( %d, %d ) and Min. Value= %d \n',ml(i,:),fV)
elseif (ConV<0)
fprintf('Saddle Point at ( %d, %d ) \n',ml(i,:))
else
fprintf('Fuurther Investigation required at ( %f, %f) \n',ml(i,:))
end
end
D =
clear
syms x y
f=2*x*y-5*x^2-2*y^2+4*x+4*y-6
fx = diff(f,x);
fy = diff(f,y);
S = vpasolve([fx==0, fy==0],[x y]);
fsurf(f)
ml = [S.x S.y];
xsy=size(ml);
ed=xsy(:,1);
for i=1:ed
fprintf('Critical Points are ( %f, %f ) \n',ml(i,:))
end
for i=1:ed
A=diff(fx,x);
AV=subs(A,{x y},{ml(i,:)});
B=diff(fx,y);
C=diff(fy,y);
Con=A*C-B^2;
ConV=subs(Con,{x y},{ml(i,:)});
fV=subs(f,{x y},{ml(i,:)});
if (ConV>0 & AV<0)
fprintf('Maximum at ( %f, %f) and Max. Value= %f \n',ml(i,:),fV)
elseif (ConV>0 & AV>0)
fprintf('Minimum at ( %f, %f) and Min. Value= %f \n',ml(i,:),fV)
elseif (ConV<0)
fprintf('Saddle Point at ( %f, %f) \n',ml(i,:))
else
fprintf('Fuurther Investigation required at ( %f, %f) \n',ml(i,:))
end
end
D =
clear
syms x y a
a=1;
f=x^3+y^3-3*a*x*y
fx = diff(f,x);
fy = diff(f,y);
S = vpasolve([fx==0, fy==0],[x y]);
ml = [S.x S.y];
fprintf('Critical Points are ( %f, %f) \n',ml(1,:))
fprintf('Critical Points are ( %f, %f) \n',ml(4,:))
xsy=size(ml);
ed=xsy(:,1);
fsurf(f)
for i=[1 ed]
A=diff(fx,x);
AV=subs(A,{x y},{ml(i,:)});
B=diff(fx,y);
C=diff(fy,y);
Con=A*C-B^2;
ConV=subs(Con,{x y},{ml(i,:)});
fV=subs(f,{x y},{ml(i,:)});
if (ConV>0 & AV<0)
fprintf('Maximum at ( %f, %f) and Max. Value= %f \n',ml(i,:),fV)
elseif (ConV>0 & AV>0)
fprintf('Minimum at ( %f, %f) and Min. Value= %f \n',ml(i,:),fV)
elseif (ConV<0)
fprintf('Saddle Point at ( %f, %f) \n',ml(i,:))
else
fprintf('Fuurther Investigation required at ( %f, %f) \n',ml(i,:))
end
end
D =
Laboratory - 5
Aim: To test whether the system of linear equations is consistent or not and hence to solve.
Procedure: 1) Construct the augmented matrix by appending the column matrix b into A i.e.[A:b]
2) Find the rank of A and [A:b]. If ranks are equal then declare system as
“Consistent” otherwise “Inconsistent”
– it will have infinite solutions if rank of A = rank of [A:b] < number of unknowns
RESULT = input(PROMPT)
displays the PROMPT string on the screen, waits for input from the keyboard, evaluates any
expressions in the input and returns the value in RESULT.
rank(A)
Activities
1) 2) 3)
clear
syms x y z
D=[x; y; z];
F=A*D;
SS=F==b
if (ra==rg)
disp('System is consistent')
sz=size(A);
S=solve([SS],{x y z});
if (ra==sz(end))
disp('System has Unique solution and is')
else
disp('System has infinite solutions and one particular solution
is')
end
disp(S)
else
disp('System is Inconsistent')
end
% To visualization of planes
fimplicit3(SS)
1.
System is Inconsistent
2.
System is consistent
3.
System is consistent
x: 48250/19893
y: 71078/19893
z: 12771/6631
Laboratory - 6
Working Rule:
Step1: Rewrite the above equations as follows:
(1)
(2)
(3)
Step3: (i) Compute using the values of and from equation (1)
(ii) Compute using the values of obtained in step 3(i) and from equation (2)
(iii) Compute using the values of and obtained in step 3(i) and (ii) from equation (3)
Step4: Repeat the above procedure for the specified number of times
Activities
1) 2) 3)
Iteration=1
x1=1.200000, x2=1.060000,x3=0.948000
Iteration=2
x1=0.999200, x2=1.005360,x3=0.999088
Iteration=3
x1=0.999555, x2=1.000180,x3=1.000053
Iteration=4
x1=0.999977, x2=0.999999,x3=1.000005
Iteration=1
x1=1.800000, x2=1.160000,x3=-0.968000
Iteration=2
x1=2.032000, x2=1.012800,x3=-0.997440
Iteration=3
x1=2.002560, x2=1.001024,x3=-0.999795
Iteration=4
x1=2.000205, x2=1.000082,x3=-0.999984
Iteration=1
x1=3.148148, x2=3.540741,x3=1.913169
Iteration=2
x1=2.432175, x2=3.572041,x3=1.925848
Iteration=3
x1=2.425689, x2=3.572945,x3=1.925951
Iteration=4
x1=2.425492, x2=3.573010,x3=1.925954
Laboratory - 7
Aim: To find the eigen value and the corresponding eigen vector by power method
Let be a real or complex number and X be a non-zero column vector which satisfies the relation
AX=X then is the eigen value and X is the corresponding eigen vector.
to get AX= X1, where is the eigen value and X1 is corresponding eigne vector
Activities
Using power method find the dominant eigne value and the corresponding eigne vector
9 1 4 10 1 1 5 −1 0 27 6 −1
1) [1 6 4] 2) [ 2 10 1 ] 3) [1 −5 1 ] 4) [ 6 15 2 ]
1 1 8 2 2 10 0 1 −5 1 1 54
clc
A=[9 1 4;1 6 1;1 1 8]
X=ones(3,1);
n=input('ENTER THE NUMBER OF ITERATIONS:\')
for i=1:n
Xn=A*X;
EVal=max(abs(Xn));
EVct=Xn/EVal;
X=EVct;
end
A = 3×3
9 1 4
1 6 1
1 1 8
n = 7
1.0000
0.2890
0.4393
V = 3×3 complex
0.8890 + 0.0000i 0.5774 + 0.0000i 0.5774 - 0.0000i
0.2540 + 0.0000i 0.5774 + 0.0000i 0.5774 + 0.0000i
0.3810 + 0.0000i -0.5774 - 0.0000i -0.5774 + 0.0000i
D = 3×3 complex
11.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 6.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 6.0000 - 0.0000i
Laboratory - 8
Aim: To solve First Order Ordinary Differential Equation and to plot their solution curves
dsolve(eqn1,eqn2, ...) accepts symbolic equations representing ordinary differential equations and
initial conditions.
By default, the independent variable is 't'. The independent variable may be changed from 't' to some
other symbolic variable by including that variable as the last input argument.
Activities: Solve and plot the solution curves for the following
1) 2)
3) 4)
5) 6)
7)
Solve
syms y(x)
Dy=diff(y);
f=dsolve(Dy+cos(x)*y==cos(x)) %General solution
fimplicit(f)
dsolve(Dy+cos(x)*y==cos(x),y(0)==0) % Particular solution
f =
ans =
Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy-y==x*exp(x)) %General solution
fimplicit(f)
dsolve(Dy-y==x*exp(x),y(0)==0) % Particular solution
Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy+y==exp(-x))
% plot the slution curve
fimplicit(f)
% solution with initial condition
dsolve(Dy+y==exp(-x), y(0) == 1)
f =
ans =
Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy+sin(x)*y==sin(x))
% plot the slution curve
fimplicit(f)
% solution with initial condition
dsolve(Dy+sin(x)*y==sin(x), y(0) == 1)
f =
ans = 1
Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy+cot(x)*y==cos(x))
f =
Solve Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy-2*y/(1+x)==1/(x+1)^3)
% plot the slution curve
fimplicit(f)
f=
Solve
clear
syms y(x)
Dy=diff(y);
f=dsolve(Dy+y*cot(x)==4*x/sin(x))
% plot the slution curve
fimplicit(f)
f =
Laboratory - 9
EUCLID'S ALGORITHM
Aim: To find Greatest Common Divisor (gcd) for two integers using Euclid's algorithm
a=b*q+r
b=r*q+r1
r=r1*q+r2
..........
rn=rn-1*q+0
clear
clc
a=input('Enter the value of a:');
b=input('Enter the value of b:');
1)
Enter the value of a:21
Enter the value of b:36
gcd(21,36) = 3
2)
Enter the value of a:-41
Enter the value of b:-17
gcd(-41,-17) = 1
3)
Enter the value of a:12
Enter the value of b:-120
gcd(12,-120) = 12
4)
Enter the value of a:0
Enter the value of b:15
Laboratory - 10
Syntax: Y = gamma(X)
Gamma Function
e
t
Γ(x) = t x 1 dt
gamma(1) ans = 1
gamma(3) ans = 2
x = 1:5; y = gamma(x)
y = 1 1 2 6 24
x = 5:10; y = gamma(x)
y = 24 120 720 5040 40320 362880
x = -3.5:3.5; y = gamma(x)
y = 0.2701 -0.9453 2.3633 -3.5449 1.7725 0.8862 1.3293 3.3234
Use fplot to plot the gamma function and its reciprocal. The gamma function increases quickly for positive arguments and has
simple poles at all negative integer arguments (as well as 0). The function does not have any zeros. Conversely, the reciprocal
gamma function has zeros at all negative integer arguments (as well as 0).
fplot(@gamma)
hold on
fplot(@(x) 1./gamma(x))
ylim([-10 10])
legend('\Gamma(x)','1/\Gamma(x)')
hold off
grid on
Beta function
Aim: Evaluate Beta Function
Syntax: B = beta(Z,W)
B = beta(Z,W)returns the beta function evaluated at the elements of Z and W. Both Z and W must be real and
nonnegative.
Beta Function
t
z 1
B(z,w)= (1 t ) w1 dt =Γ(z) Γ(w) / Γ(z+w).
0
t
Z 1
The Γz term is the gamma function Γ(z) = e z dt
0
Z — Input array scalar | vector | matrix | multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array. The elements of Z must be real and nonnegative. Z and W
must be the same size, or else one of them must be a scalar.
W — Input array scalar | vector | matrix | multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array. The elements of W must be real and nonnegative. Z and W
must be the same size, or else one of them must be a scalar.
B = beta(3/2,5/2) B = 0.1963
Set the output format to rational to show the results as ratios of integers.
format rat
B = beta((1:10)',3)
B = 1/3 1/12 1/30 1/60 1/105 1/168 1/252 1/360 1/495 1/660
Calculate the beta function for z = 0.05, 0.1, 0.2, and 1 within the interval 0≤w≤10. Loop over values of z, evaluate the function at
>> B
ANS B =
Columns 1 through 9