Consider the following two functions, f(x) = e^-x sin(2x), g(x) = e^(-3/4 x) cos
ID: 3824570 • Letter: C
Question
Consider the following two functions, f(x) = e^-x sin(2x), g(x) = e^(-3/4 x) cos(2x). (a) Write a code to generate 100 points of x between 0 and 5. (b) Write a code to plot f(x) as a function of x, using a 2-point-wide solid blue line. (c) Write a code to plot g(x) on the same plot (where f(x) was plotted) as a function of x. Use a 1.5- point-wide dashed red line. (d) Include an appropriate title. Use Latex format to write and include formulas in your title. For example, try the following code to generate the title for your plot. title('$f(x) = ??? mbox (and) g(x) = ??? $', 'Interpreter', 'latex') The 'mbox' command is being used to embed 'text' in your formula. Replace above '???' and complete formulas for f(x) and g(x) in your title. (e) Similarly include appropriate axis labels and legend using Latex format. Be careful, in the case of legends, you need to create a cell array of formulas. (f) Make sure your grid lines are turned on. Also turn on your 'minor' grid lines.Explanation / Answer
x = rand(1,100)*5;
fx = @(x) exp(-x) * sin(2*x);
gx = @(x) exp(-3*x/4) * cos(2*x);
yfx = arrayfun(fx, x);
ygx = arrayfun(gx, x);
figure
plot (x,yfx,'b', 'LineWidth',2,x,ygx,'r', 'LineWidth', 1.5)
title('$f(x)=e^-x * sin(2x) mbox{ and ) g(x)=e-(-3/4 x)*cos(2x) $', 'Interpreter','latex')
As per the chegg answering rules, I have answered the first 4 subparts of the question. Incase you are facing any problem with the code, please let me know. I shall be glad to help you with the code.