Professional Documents
Culture Documents
Experiment No.-8: Aim:-Tool Used: - Program Code
Experiment No.-8: Aim:-Tool Used: - Program Code
Experiment No.-8: Aim:-Tool Used: - Program Code
-8
Aim:-To write a MATLAB program to compute factorial for n=50.
Tool Used:-MATLAB 7.0.4.
Program Code
f=1;
for i=1:1:50
f=f*i;
end
fprintf(factorial of 50 is=%d,f)
Output
factorial of 50 is=3.041409e+64
Experiment No.-9
Program code
s=0; k=0;
while k<=49
s=s+2k;
k=k+1;
end
fprintf(sum of powers of 2 below fifty is=%d,s)
Output
Experiment No.-10
Aim:-To write a MATLAB program to
Output
Enter a number
10
n = 10
0
1
1
2
3
5
8
13
21
34
55
Experiment No.-11
Aim:-To write a MATLAB program to plot a circle of radius 5.
Tool Used:-MATLAB 7.0.4.
Program Code
t=-5:.001:5
y=5*cos(t);
x=5*sin(t);
plot(x,y)
Output
Experiment No.-12
Aim:-To write a MATLAB program to plot the following curves
(1)sinc(x)
(2)(1/(x-1)2)+x
(3)(x2+1)/(x2-4)
(4)((10-x)2/3-2)/(4-x2)1/2
Tool Used:-MATLAB 7.0.4.
Program Code
x=-3*pi:.001:3*pi
y=sinc(x)
subplot(2,2,1)
plot(y),xlabel(x),ylabel('sinc(x)')
x=-5:.05:5
y=(1./(x-1).^2)+x
subplot(2,2,2)
plot(y),xlabel('x'),ylabel('y=(1./(x-1).^2)+x')
x=-5:.05:5
y=(x.^2+1)./(x.^2-4)
subplot(2,2,3)
plot(y),xlabel('x'),ylabel('y=(x.^2+1)./(x.^2-4)')
x=-10:.001:10
y=(((10-x).^(2/3))-2)./(4-x.^2).^(1/2)
subplot(2,2,4)
plot(y),xlabel('x'),ylabel('y=(((10-x).^(2/3))-2)./(4-x.^2).^(1/2)')
Output