I tried to do my homework and i'm not sure if I did it right. I'm not entirely sure how linspace works and was hoping for some input on my code! I'll attach the assignment it's based on. [enter link description here][1] [enter image description here][2]
clc
clear all
figure(1);
figure(1);
x = 0:0.1:10
y1 = exp(-0.5*x).*sin(2*x)
y2 = exp(-0.5*x).*cos(2*x)
plot(x,y1,'-b',x,y2,'--r')
legend('y1','y2');
grid on
xlabel('\bfx axis');
ylabel('\bfy axis');
title('Sin and Cos Functions')
figure(2);
subplot(2,2,1)
plot(x,y1,'-b');
legend('y1','Location','northeast');
grid on
xlabel('\bfx')
ylabel('\bfy1')
title('Subplot of x and y1')
figure(3)
subplot(2,2,2)
plot(x,y2,'--r');
legend('y2','Location','northeast');
grid on
xlabel('\bfx')
ylabel('\bfy2')
title('Subplot of x and y2')
figure(4)
x = linspace(-2,8,200);
fun=(x.^2-6*x+5)./(x-3)
plot(x,fun,'b-','LineWidth',2)
axis([-2 8 -10 10]);
hold on;
title('Plot of f(x)')
xlabel('\bfx')
ylabel('\bfy')
(50 Points) Plot the function y(x) = (e^-0.5x)(Sin2x) for 100 values of x between 0 and 10. Use solid blue line for this function. Then plot the function y(x) = (e^-0.5x)(Cos2x)on the same axis. Use dashed red line for this function. Be sure to include a legend, title, axis labels and grid on the plots. Re-graph the two functions using subplot.
(50 Points) Plot the function Plot the function f(x)= ((X^2)-6x-5)/(x-3) using 200 points over the range −2 ≤ x ≤ 8. Note that there is an asymptote at x = 3, so the function will tent to infinity near to that point. In order to see the rest of the plot properly, you will need to limit the y-axis to the range -10 to 10.