Question

In: Computer Science

Write as a MatLab script For X=-2π~2π with intervals of π/100. a. Plot Y1=sin(X) as a...

Write as a MatLab script

For X=-2π~2π with intervals of π/100.
a. Plot Y1=sin(X) as a red line. Add a grid. b. Plot Y2=cos(X) as a black dotted line. Add a grid. c. Plot Y1 and Y2 in the same plot without using the hold on/off command. d. For Y3= Y1 times Y2, plot Y1, Y2 and Y3 in the same graph. Y3 will be green line. Add title, axis label and a legend.

Solutions

Expert Solution


%   MATLAB Program to plot multple functions on a same graph

X = -2*pi:pi/100:2*pi;

%   (a)
Y1 = sin(X);
plot(X,Y1,'r');
grid on;

%   (b)
Y2 = cos(X);
plot(X,Y2,'.-k');
grid on;

%   (c)
plot(X,Y1,'r',X,Y2,'.-k');
grid on;

%   (d)
Y3 = Y1 .* Y2;
plot(X,Y1,'r');
hold on
plot(X,Y2,'.-k');
plot(X,Y3,'g');
hold off
grid on;

title('Sin(x) & Cos(x)');
xlabel('x-axis');
ylabel('y-axis');
legend('Y1','Y2','Y3');


Related Solutions

f(x,y)=sin(2x)sin(y) intervals for x and y: -π/2 ≤ x ≤ π/2 and -π ≤ y ≤...
f(x,y)=sin(2x)sin(y) intervals for x and y: -π/2 ≤ x ≤ π/2 and -π ≤ y ≤ π find extrema and saddle points In the solution, I mainly interested how to findcritical points in case of the system of trigonometric equations (fx=0 and fy=0). ,
Using Matlab, Write a script that validates the relationship between sin u, cos u, and tan...
Using Matlab, Write a script that validates the relationship between sin u, cos u, and tan u by evaluating these functions at suitably chosen values. Please screenshot Matlab screen. Thank you!
1.The domain of r(t)=〈sin(t),cos(t),ln(t+1)〉 is Select one: a. (−∞,−1] b. (π,2π) c. (−∞,−2] d. (−π,2π) e....
1.The domain of r(t)=〈sin(t),cos(t),ln(t+1)〉 is Select one: a. (−∞,−1] b. (π,2π) c. (−∞,−2] d. (−π,2π) e. ℝ f. (−1,∞) 2. The limt→πr(t) where r(t)=〈t2,et,cos(t)〉 is Select one: a. 〈π2,eπ,−1〉 b. undefined c. 〈π2,eπ,1〉 d. π2+eπ e. 〈π2,eπ,0〉 3.Let v(t)=〈2t,4t,t2〉. Then the length of v′(t) is Select one: a. 20‾‾‾√+2t b. 20+4t2 c. 20+2t‾‾‾‾‾‾‾√ d. 20+4t2‾‾‾‾‾‾‾‾√ e. 6+2t‾‾‾‾‾‾√ f. 1 4. The curvature of a circle centred at the origin with radius 1/3 is Select one: a. 1 b. 1/3 c....
This code is to be written in Matlab. Write a function that will plot cos(x) for...
This code is to be written in Matlab. Write a function that will plot cos(x) for x values ranging from -pi to pi in steps of 0.1, using black *'s. It will do this three times across in one Figure Window, with varying line widths. If no arguments are passed to the function, the line widths will be 1, 2, and 3. If on the other hand, an argument is passed to the function, it is multiplier for these values....
a MATLAB script that: • Prompts the user for - a lower-bound for the plot interval...
a MATLAB script that: • Prompts the user for - a lower-bound for the plot interval and stores it in a variable named Lbound - an upper-bound for the plot interval and stores it in a variable named Ubound, and - the number of points at which a function is to be evaluated to generate a plot of the function over the specified range and stores it in a variable named npoints. • Generates a plot of f(x) = x3...
Write your own MATLAB code to solve the system 10 − x + sin(x + y)...
Write your own MATLAB code to solve the system 10 − x + sin(x + y) − 1 = 0 8y − cos2 (z − y) − 1 = 0 12z + sin(z) − 1 = 0 using a residual tolerance of 10^−6 and the initial guess, ~x 0 = [0.1, 0.25, 0.08]^T . Print out the values for x, y and z for each iteration in a table similar to the one you created for the problems of the...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
Consider the function on the interval (0, 2π). f(x) = sin(x) cos(x) + 2 (a) Find...
Consider the function on the interval (0, 2π). f(x) = sin(x) cos(x) + 2 (a) Find the open interval(s) on which the function is increasing or decreasing. (Enter your answers using interval notation.) increasing     ( )    decreasing     ( )   (b) Apply the First Derivative Test to identify all relative extrema. relative maxima     (x, y) =    (smaller x-value) (x, y) = ( )    (larger x-value) relative minima (x, y) =    (smaller x-value) (x, y) = ​   ...
Find the Fourier series for the function on the interval (-π,π) f(x) = 1 -sin(x)+3cos(2x) f(x...
Find the Fourier series for the function on the interval (-π,π) f(x) = 1 -sin(x)+3cos(2x) f(x )= cos2(x) f(x) = sin2(x)
Write a MATLAB script file that will give the value of f(x) using method of least...
Write a MATLAB script file that will give the value of f(x) using method of least squares and asks the user to enter values of x, y, n (curve fit), and x for f(x).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT