Experiment No: 5 AIM: Creating A Vector X With Elements, X: 'Plotting Function X' 'X-Axis' 'Y-Axis'
Experiment No: 5 AIM: Creating A Vector X With Elements, X: 'Plotting Function X' 'X-Axis' 'Y-Axis'
Experiment No: 5 AIM: Creating A Vector X With Elements, X: 'Plotting Function X' 'X-Axis' 'Y-Axis'
AIM: Creating a vector X with elements, Xn = ((-1)^(n+1))/(2n-1) and Adding up 100 elements
of the vector, X; And, plotting the functions, x, x2,x3 , exp(x) , exp(x2 ) over the interval 0 < x <
4 (by choosing appropriate mesh values for x to obtain smooth curves), on A Rectangular Plot.
TOOL USED: Matlab version (R2018a), Command window, Editor.
THEORY:
PROGRAM:
1. Creating a vector X having 100 elements and then adding 100 elements of vector X.
n = 0:100;
Xn = [(-1).^(n+1)]/(2*n-1);
y = Xn
sum(y);
disp(y);
plot(y);
i) x = 0:1:4
subplot(511);
plot(x)
title('Plotting function X')
xlabel('X-axis')
ylabel('Y-axis')
ii) a = x.^2
subplot(512);
plot(a)
title('Plotting Square of X')
xlabel('X-axis')
ylabel('Y-axis')
iii) b = x.^3
subplot(513);
plot(b)
title('Plotting Cube of X')
xlabel('X-axis')
ylabel('Y-axis')
iv) c = exp(x)
subplot(514);
plot(c)
title('Plotting Exponential of X')
xlabel('X-axis')
ylabel('Y-axis')
v) d = exp(x.^2)
subplot(515);
plot(d)
title('Plotting Exponential of square of X')
xlabel('X-axis')
ylabel('Y-axis')
OBSERVATION:
1. Output of Xn = [(-1).^(n+1)]/(2*n-1)].
2. Output of function x,x2,x3,exp(x),exp(x2).
RESULT:
We have successfully Created a vector and store 100 elements into it and than we add all of them
and successfully plot them as well as we have successfully plot all the function x, x2, x3, exp(x),
exp(x2) on a single plot using subplot.