23MAT107 Calculus Lab2
23MAT107 Calculus Lab2
23MAT107 Calculus Lab2
23MAT107
Calculus
Lab Practice Sheet-2
➢ t=-10:0.01:10; plot(t, t.^2) Plots the function f(x)=x2 in [-10,10] using the
parametric form of the function
➢ t=0:0.0001:2*pi; plot(cos(t), sin(t)) Plots the unit circle with centre at origin using
parametric form
➢ x=-10:1:10; y=x.^2; stem(x, y) Gives the stem plot of the function f(x)=x2 in [-10,10]
To Plot a line segment from a point A(a1, a2) to a point B(b1, b2)
➢ Click on on top left of the MATLAB window, to create a new script file(m-file) and type
the following in it. After typing save the file as circle and run it. Look out for the figure which
appears in the figure window.
plots a circle with unit radius
theta = linspace(0,2*pi,100);
x=cos(theta); centred at the origin with
y=sin(theta); title and labels for axes.
plot(x,y)
axis('equal')
xlabel('x')
ylabel('y')
title('Circle of unit radius centred at the origin')
➢ Create a script file(M-file), type the following in it, save the file as multiple plot and execute it. Look
out for the figure which appears in the figure window
t = -4*pi:pi/50:4*pi;
plot3(sin(t), cos(t), t) plots a three-dimensional curve
grid on
- circular helix using parametric
axis square
xlabel('x') representation with labelling of
ylabel('y') axis and title for the figure
zlabel('z')
title( ‘Circular helix’)
Click on top left of the MATLAB window, to create a new live script file. You can see the videos
given in the link below, to learn more about how to easily work with live scripts.
https://www.youtube.com/watch?v=tNcSpyCa6bc (this video also starts with basic MATLAB)
https://in.mathworks.com/videos/using-the-live-editor-117940.html
Practise Questions
1. Plot 𝑦 = 𝑠𝑖𝑛𝑥, 𝑥 = −2𝜋 𝑡𝑜 2𝜋.
2. Plot 𝑦 = 𝑡𝑎𝑛𝑥, 𝑥 = −2 𝑡𝑜 2.
3. Write a programme to plot a circle with radius 5 and centre at (1,1).
4. Write a programme to plot the ellipse (𝑥 − 3)2 + 9(𝑦 − 5)2 = 9.
(Use parametric representation).
𝑥2 𝑦2
5. Write a programme to plot the ellipse 25 + = 1 in the second quadrant.
9
6. Plot 𝑦 = 𝑠𝑖𝑛𝑥 and 𝑦 = 𝑐𝑜𝑠𝑥 in the same window with different colours and different line
styles between −4𝜋 to 4𝜋. Ensure that the X and Y axis are seen in the plot.
7. Solve the given linear system geometrically using MATLAB.
𝑥 + 𝑦 = 6; 2𝑥 – 𝑦 = 9.
8. Solve the given linear system geometrically as well as by using X= A\B in MATLAB.
𝑥 + 𝑦 + 𝑧 = 6; 2𝑥 – 𝑦 + 𝑧 = 5; 3𝑥 + 2𝑦 − 5𝑧 = 8.
9. Plot the 3-dimensional curve given by 𝑦 = 𝑥 and 𝑧 = 𝑥 2 in the interval 𝑥 𝜖 (−100,100).
10. Plot the 3-dimensional curve given by 𝑦 = 𝑠𝑖𝑛𝑥 and 𝑧 = 𝑥 2 in the interval 𝑥 𝜖 (−100,100).
11. Plot the 3-dimensional elliptical helix, which has the parametric representation as
̅̅̅̅̅ = [5𝑐𝑜𝑠𝑡, 3𝑠𝑖𝑛𝑡, 𝑡 + 1], −4𝜋 < 𝑡 < 4𝜋
𝑟(𝑡)
̅̅̅̅̅ = [𝑐𝑜𝑠𝑡, 𝑠𝑖𝑛𝑡, 𝑡], −4𝜋 < 𝑡 < 4𝜋 in different colours in the
along with the circular helix 𝑟(𝑡)
same figure window.
𝑥, 0 ≤ 𝑥 ≤ 1
12. Plot the function: 𝑓(𝑥) = { 1, 1 < 𝑥 ≤ 2 }.
3 − 𝑥, 2 ≤ 𝑥 ≤ 3
1, −10 ≤ 𝑥 ≤ −1
13. Plot the function: 𝑓(𝑥) = { −𝑥, − 1 < 𝑥 ≤ 1 },
𝑥 − 2, 1 ≤ 𝑥 ≤ 10
3𝜋
sin 𝑥, − 2 ≤ 𝑥 ≤ 0
𝜋
14. Plot the function: g(𝑥) = 2𝑥, 0 < 𝑥 ≤ 2
𝜋 3𝜋
𝜋 − cos 𝑥 , 2 ≤ 𝑥 ≤
{ 2}
15. Draw a line segment from a point 𝐴(𝑥, 𝑦) to 𝐵(𝑦, 𝑧) using a single command in MATLAB,
where 𝑥 is the date, 𝑦 is the month and 𝑧 is the year (last two digits) in your date of birth. Also
have the 𝑋 axis and 𝑌 axis in the figure.