0% found this document useful (0 votes)
2 views18 pages

Mathematics Lab Scripts for B.Sc.

The document contains a series of MATLAB script files designed for a Mathematics Lab course for B.Sc. students in the 2025-26 academic year. Each script generates plots for various mathematical functions, including linear, polynomial, exponential, logarithmic, and trigonometric functions, as well as operations on matrices and complex numbers. The scripts are structured to provide visual representations and calculations relevant to the mathematical concepts being taught.

Uploaded by

satyam91994194
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views18 pages

Mathematics Lab Scripts for B.Sc.

The document contains a series of MATLAB script files designed for a Mathematics Lab course for B.Sc. students in the 2025-26 academic year. Each script generates plots for various mathematical functions, including linear, polynomial, exponential, logarithmic, and trigonometric functions, as well as operations on matrices and complex numbers. The scripts are structured to provide visual representations and calculations relevant to the mathematical concepts being taught.

Uploaded by

satyam91994194
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link].

(Mathematics), Sem-I, 2025-26, Mathematics Lab

1. % A script file that creates a plot of the function: ax


x=0:0.1:5;
for i=1:3
if i==1
a=0.8;
y1= a*x;
elseif i==2
a=1;
y2= a*x;
else
a=1.5;
y3= a*x;
end
end
plot(x,y1,'*', x,y2,'-',x,y3,'+');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y \rightarrow ','FontSize',20);
legend({'a = .8','a = 1','a = 1.5'},'FontSize',20);

1
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

2. % A script file that creates a plot of the function: x^2n


x=0:.05:2;
for i=1:3
if i==1
n=1;
y1= power(x,2*n);
else
n=2;
y2= power(x,2*n);
end
end
plot(x,y1,'*', x,y2,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y \rightarrow ','FontSize',20);
legend({'n = 1','n = 2'},'FontSize',20);

2
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

3. % A script file that creates a plot of the function: e^x

x=0:.05:2;
y=exp(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = e^x \rightarrow ','FontSize',20);

3
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

4. % A script file that creates a plot of the function: e^-x

x=0:.05:3;
y=exp(-x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
[Link]('\fontname{Times New Roman} y = exp(-x) \rightarrow ','FontSize',20);

4
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

5. % A script file that creates a plot of the function: log(x)

x=0:.05:10;
y=log(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = log(x) \rightarrow ','FontSize',20);

5
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

6. % A script file that creates a plot of the function: sin(x)

x=0:.05:15;
y=sin(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = sin(x) \rightarrow ','FontSize',20);

6
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

7. % A script file that creates a plot of the function: cos(x)

x=0:.05:15;
y=cos(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = cos(x) \rightarrow ','FontSize',20);

7
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

8. % A script file that creates a plot of the function: tan(x)

x=0:.05:5;
y=tan(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = tan(x) \rightarrow ','FontSize',20);

8
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

9. % A script file that creates a plot of the function: sinh(x)

x=0:.05:5;
y=sinh(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = sinh(x) \rightarrow ','FontSize',20);

9
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

10. % A script file that creates a plot of the function: cosh(x)

x=0:.05:5;
y=cosh(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = cosh(x) \rightarrow ','FontSize',20);

10
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

11. % A script file that creates a plot of the function: tanh(x)

x=0:.05:10;
y=tanh(x);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = tanh(x) \rightarrow ','FontSize',20);

11
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

12. % A script file that creates a plot of the polynomial of degree 2

x=0:.05:5;
y=2+3.*x+4.*x.*x;
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = 2+3x+4x^2 \rightarrow ','FontSize',20);

12
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

13. % A script file that creates a plot of the polynomial of degree 3

x=0:.05:5;
y=3+5.*x+2.*x.*x+4.*power(x,3);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = 3+5x+2x^2+4x^3 \rightarrow
','FontSize',20);

13
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

14. % A script file that creates a plot of the polynomial of degree 4

x=0:.01:2;
y=2+3.*x-4.*x.*x+3.*power(x,4);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = 2+3x-4x^2+3x^4 \rightarrow
','FontSize',20);

14
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

15. % A script file that creates a plot of the polynomial of degree 5

x=0:.01:2;
y=1+10.*x-20.*x.*x-2.*power(x,4)+2.*power(x,5);
plot(x,y,'-');
xlabel('\fontname{Times New Roman} x \rightarrow ','FontSize',20);
ylabel('\fontname{Times New Roman} y = 1+10x-20x^2-2x^4+2x^5 \rightarrow
','FontSize',20);

15
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

16. % A script file that creates a Matrix addition and Multiplication

A=[2, 5, 6; 8, 4, 9; 3, 7, 0]
B= [5, 14, 21; 9, 24, 52; 8, 5, 72]
Addition= A+B
Multiplication=A*B
Output:
A=
2 5 6
8 4 9
3 7 0
B=
5 14 21
9 24 52
8 5 72
Addition =
7 19 27
17 28 61
11 12 72
Multiplication =
103 178 734
148 253 1024
78 210 427

16
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

17. % A script file that creates a matrix transpose and inverse

A=[2,5,6;8, 4, 9; 5, 2, 10]
Transpose = A'
D= det(A)
if D==0
disp('Inverse can not be evaluated');
else
Inverse=inv(A)
end
Output:
A=
2 5 6
8 4 9
5 2 10
Transpose =
2 8 5
5 4 2
6 9 10
D=
-155
Inverse =
-0.1419 0.2452 -0.1355
0.2258 0.0645 -0.1935
0.0258 -0.1355 0.2065

17
[Link]. (Mathematics), Sem-I, 2025-26, Mathematics Lab

18. % A script file that creates addition, multiplication, modulus and division of complex
numbers

z1=2+3i

z2=5+7i

Addition= z1+z2

Multiplication=z1*z2

Modulus= abs(z1)

Division=z1/z2

Output:

z1 =

2.0000 + 3.0000i

z2 =

5.0000 + 7.0000i

Addition =

7.0000 +10.0000i

Multiplication =

-11.0000 +29.0000i

Modulus =

3.6056

Divison =

0.4189 + 0.0135i

18

You might also like