% plot the function y1=sin(t) and y2=sin(10*t) in the time interval [0 2*pi] close all clc clear all % define the time vector time1=linspace(0, 2*pi,50); % time vector in [0 2 pi] with 50 equispaced elements % which are sufficient to plot % y1 but not for y2 % the time period of y2 is equal to 2*pi/10, increase the number of % elements (points/samples) to plot y2 in [0 2*pi] time2=linspace(0,2*pi,500); % define y1 y1=sin(time1); figure(1) hold on grid on plot(time1,y1,'-k','linewidth',2); xlabel('time [t]','fontsize',12) % label for x axis ylabel('y','fontsize',12) % label for y axis % define y2 y2=sin(10*time2); plot(time2,y2,'-r','linewidth',2) legend({'y=sin(t)','y=sin(10t)'},'fontsize',12) title('sinusoidal functions') %%%%%%%%%%%%%%%%%%%%%%% %%% plots using subplot %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%% f=figure(2); subplot(2,1,1) %%% plot of y=sin(t) hold on grid on plot(time1,y1,'-k','linewidth',2); ylabel('y_1') title('y_1=sin(t)'); subplot(2,1,2) %%% plot of y=sin(10*t) hold on grid on plot(time2,y2,'-r','linewidth',2) xlabel('t'); ylabel('y_2') title('y_2=sin(10t)');