% run this script to plot pseudo-periodic functions as % y= exp(-t/tau).*sin(omega*t), % with different values of tau and omega clear all close all clc % define tau and omega tau=5; omega=3; % define time vector t_0=0; %initial value t_f=20; % final value t_s=0.01; % step time t=t_0:t_s:t_f; % time vector % define exp function y_exp=exp(-t/tau); % define sin function y_sin=sin(omega*t); % define y, a pseudo-periodic function y=y_exp.*y_sin; % plot y, y_exp and y_sin in figure 1 figure (1) hold on grid on xlabel('time') ylabel('y') plot(t,y,'-r','linewidth',2) plot(t,y_exp,'--b'); plot(t,y_sin,'--g'); % define exp. modes with different tau values tau_a=3; tau_b=6; y_exp_a=exp(-t/tau_a); y_exp_b=exp(-t/tau_b); % define sin functions with different omega values omega_1=1; omega_2=2; y_sin_1=sin(omega_1*t); y_sin_2=sin(omega_2*t); figure (2) % plot in figure 2 differents exp, periodic and pseudo periodic funtions subplot(2,2,1) % plot exp. modes hold on grid on plot(t, y_exp_a,'-b'); plot(t, y_exp_b,'-r'); ylabel('y') %xlabel('t') legend('y_1=e^{-t/3}','y_2=e^{-t/6}') % plot sin functions (periodic modes) subplot(2,2,2) hold on grid on plot(t, y_sin_1,'-k'); plot(t, y_sin_2,'-g'); legend('y_1=sin(t)','y_2=sin(2t)') %xlabel('t') %ylabel('y') % plot exp(-t/3), exp(-t/6), sin(t), exp(-t/3).*sin(t) % and exp(-t/6).*sin(t) subplot(2,2,3) hold on grid on y_pseudo_1a=y_exp_a.*y_sin_1; y_pseudo_1b=y_exp_b.*y_sin_1; plot(t, y_exp_a,'--b'); plot(t, y_exp_b,'--r'); plot(t, y_sin_1,'--k'); plot(t,y_pseudo_1a,'-b','linewidth',3) plot(t,y_pseudo_1b,'-r','linewidth',3) legend('y_1=e^{-t/3}','y_2=e^{-t/6}','y_3=sin(t)','y_4=y_1 y_3','y_5=y_2 y_3'); xlabel('t') ylabel('y') % plot exp(-t/3), exp(-t/6), sin(2t), exp(-t/3).*sin(2t) % and exp(-t/6).*sin(2t) subplot(2,2,4) hold on grid on y_pseudo_2a=y_exp_a.*y_sin_2; y_pseudo_2b=y_exp_b.*y_sin_2; plot(t, y_exp_a,'--b'); plot(t, y_exp_b,'--r'); plot(t, y_sin_2,'--g'); plot(t,y_pseudo_2a,'-c','linewidth',3) plot(t,y_pseudo_2b,'-m','linewidth',3) xlabel('t') %ylabel('y') legend('y_1=e^{-t/3}','y_2=e^{-t/6}','y_3=sin(2t)','y_4=y_1 y_3','y_5=y_2 y_3');