Question

In: Mechanical Engineering

This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...

This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications:

Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4.

The plot should have:

(1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin (2*x)’, ‘y= y=2*sin(x)’ and title = ‘x Vs. y’ under Font Name of Times New Roman, and Font Size of 14 pt. for all subplot location.

(2) For sine(x) use red solid line, for cos(x) use blue dashed line, for sin(2*x) use green dash-dot line, and for 2*sin(x) use solid line and RGB [0.5 0.2 0.2]

(3) Create minor grid for all subplot location.

Please attach editor code and the figure in your answer. Thank You!

Solutions

Expert Solution

figure

subplot(2,2,1)
x = 1:0.1:10;
y1 = sin(x);
plot(x,y1,'r')
set(gca,'FontSize',14,'FontName','Times New Roman')
grid(gca,'minor')
grid on
set(gca, 'YMinorTick','on', 'YMinorGrid','on')
xlabel('x value');
ylabel('y value');
legend('y = sin(x)');
title('x Vs. y')

subplot(2,2,2)
y2 = cos(x);
plot(x,y2,'b--')
set(gca,'FontSize',14,'FontName','Times New Roman')
grid(gca,'minor')
grid on
set(gca, 'YMinorTick','on', 'YMinorGrid','on')
xlabel('x value');
ylabel('y value');
legend('y = cos(x)');
title('x Vs. y')

subplot(2,2,3)
y3 = sin(2*x);
plot(x,y3,'g-.')
set(gca,'FontSize',14,'FontName','Times New Roman')
grid(gca,'minor')
grid on
set(gca, 'YMinorTick','on', 'YMinorGrid','on')
xlabel('x value');
ylabel('y value');
legend('y = sin(2x)');
title('x Vs. y')

subplot(2,2,4)
y4 = 2*sin(x);
plot(x,y4,'color',[0.5 0.2 0.2])
set(gca,'FontSize',14,'FontName','Times New Roman')
grid(gca,'minor')
grid on
set(gca, 'YMinorTick','on', 'YMinorGrid','on')
xlabel('x value');
ylabel('y value');
legend('y = 2sin(x)');
title('x Vs. y')


Related Solutions

Write the MATLAB code to Create a new figure. Define a theta array such that ?...
Write the MATLAB code to Create a new figure. Define a theta array such that ? 2 ≤ ? ≤ 9? 2 with increment of ? 10 ; Create a sixmember array of ones called r. Create a new polar plot of ? versus r
**MATLAB Code only Please create a MATLAB script that is a TIC-TAC-TOE game. Please keep it...
**MATLAB Code only Please create a MATLAB script that is a TIC-TAC-TOE game. Please keep it simple, but there is no other rules. Thank you.
Use Matlab to do the following (please) : 1. Plot the following signals in one figure...
Use Matlab to do the following (please) : 1. Plot the following signals in one figure window using Matlab commands. Given x (n) = {5,2,1,3,1,4,2} plot x(3n) 2. Plot all transformations of a Gaussian signal in one figure window 3. Plot r(-3t-9).
The following code must be written using matlab Create a contour plot of the following function...
The following code must be written using matlab Create a contour plot of the following function f(x,y) = (x+y^2-10)^2 +(x^2+y^2+8) in range [-6,6] for both x and y Clearly indicate in the plot the coordinates of the minimum ponts and the the corresponding function values in these points
Use MATLAB to figure out the following problem, if you do not know how to use...
Use MATLAB to figure out the following problem, if you do not know how to use MATLAB then please do not answer. Coding is required for the exercise. For f(x) = arctan(x), find its zeros by implimenting Newtons method and the Secant method in Matlab. (Hint: Use Newtons method to calculate x1 for Secant method) Comment all code please since I would like to learn how to do this correctly in MATLAB. Thank you.
Coding: Use MATLAB to figure out the following problem, if you do not know how to...
Coding: Use MATLAB to figure out the following problem, if you do not know how to use MATLAB then please do not answer. Coding is required for the exercise. For f(x) = arctan(x), find its zeros by implimenting Newtons method and the Secant method in Matlab. (Hint: Use Newtons method to calculate x1 for Secant method) Comment all code please since I would like to learn how to do this correctly in MATLAB. Thank you.
Matlab Code that does the following: Takes as input 3 frequencies. Create a signal that is...
Matlab Code that does the following: Takes as input 3 frequencies. Create a signal that is a mixture of the 3 signals. Create a bandpass filter that only selects the center frequency. Output the filtered signal which contains only the middle frequency. Plot in time and frequency domain the original signal and the filtered signal. Show the output for filter order 1 and 15. Upload a pdf of the image files. Each figure should have your name in the title...
I need to write a MATLAB code for this question, but I couldn't figure how to...
I need to write a MATLAB code for this question, but I couldn't figure how to do it. 7. Engineers often have to convert from one unit of measurement to another; this can be tricky sometimes. You need to think through the process carefully. For example, convert 5 acres to hectares, given that an acre is 4840 square yards, a yard is 36 inches, an inch is 2.54 cm, and a hectare is 10000 m2.
The Monty Hall problem solved on Matlab. Please show code. You are given a choice between...
The Monty Hall problem solved on Matlab. Please show code. You are given a choice between three doors. Behind one door is a new car and behind the other two doors is a goat. You first pick one of the doors at random. Then, a door with a goat is opened for you. You are then given the option to switch your door to the other unopened door. Should you do this? What are your odds of winning if you...
Create a matlab function that converts Miles per hour to feet per second. Please show code...
Create a matlab function that converts Miles per hour to feet per second. Please show code in matlab
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT