0% found this document useful (0 votes)
25 views3 pages

Math Lab Assignment 1

The document provides instructions for plotting various mathematical functions using MATLAB. It includes specific tasks such as plotting y=cos(3x), y=x^2 + 4x + 5, and both y=sin(2x) and y=cos(2x) on the same axes, along with y=cos(x) and y=x^3 over specified intervals. Each task emphasizes labeling axes, adding titles, and including grid lines for clarity.

Uploaded by

lakshana.k2025
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)
25 views3 pages

Math Lab Assignment 1

The document provides instructions for plotting various mathematical functions using MATLAB. It includes specific tasks such as plotting y=cos(3x), y=x^2 + 4x + 5, and both y=sin(2x) and y=cos(2x) on the same axes, along with y=cos(x) and y=x^3 over specified intervals. Each task emphasizes labeling axes, adding titles, and including grid lines for clarity.

Uploaded by

lakshana.k2025
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
You are on page 1/ 3

VIT®

-; • • I\ Vellort- Institute of ·1cch11ology


(Dttmt4 tt bt l 1iunity ndu uctio1 Jor tb l G( Ac~ 1~)
VELl~ORE CAMPUS

Lakshana.K

25MPI0001
HOSTELLER

1. Plot the function y=cos(3x) over the interval [0, 2π]. Label the
axes and add an
appropriate title.

x = linspace(0, 2*pi, 500);


y = cos(3*x);

gure;
plot(x, y);
title('Plot of y = cos(3x)’);
xlabel('x');
ylabel('y');
grid on;

2. Plot y = x^2 + 4x + 5 over


the interval [-2, 2] using 100 data points. Make sure the graph
fi
includes grid lines.

x = linspace(-2, 2, 100);
y = x.^2 + 4*x + 5;

gure;
plot(x, y);
title('Plot of y = x^2 + 4x +
5');
xlabel('x');
ylabel('y');
grid on;

3. Plot both y = sin(2x) and


y = cos(2x) on the same axes using di erent styles. Include a
legend to distinguish between the two curves.

x = linspace(0, 2*pi, 500);


y1 = sin(2*x);
y2 = cos(2*x);

gure;
plot(x, y1, '--', 'LineWidth', 2);
hold on;
plot(x, y2, '-', 'LineWidth', 2);
hold o ;
title('Plot of y = sin(2x) and y
= cos(2x)');
xlabel('x');
ylabel('y');
legend('y = sin(2x)', 'y = cos(2x)');
grid on;

4. Plot the functions y = cos(x), y = x^3 on the interval [-π, π].


fi
fi
ff
ff
x = linspace(-pi, pi, 500);
y1 = cos(x);
y2 = x.^3;

gure;
plot(x, y1, 'b', 'LineWidth', 2);
hold on;
plot(x, y2, 'r', 'LineWidth', 2);
hold o ;
title('Plot of y = cos(x) and y = x^3');
xlabel('x');
ylabel('y');
legend('y = cos(x)', 'y = x^3');
grid on;
fi
ff

You might also like