% plot function y as sum of two aperiodic modes (real exponential functions) % y= exp(-t)+4*exp(-4t) % clear all close all clc % define exp coefs. lambda_1=-1; lambda_2=-4; % define the corresponding time constants tau_1=-1/lambda_1; tau_2=-1/lambda_2; % define time vector (final time, t_f, and, sampling time, t_s) if tau_1>=tau_2 t_f=5*tau_1; t_s=tau_2/10; else t_f=5*tau_2; t_s=tau_1/10; end % time vector time=0: t_s:t_f; % or time=0:0.01:5 % define y1 y1=exp(lambda_1*time); % define y2 y2=4*exp(lambda_2*time); %define y y=y1+y2; % plot y, y1 and y2 figure(1) plot(time,y1,'-b'); hold on grid on plot(time,y2,'-r'); plot(time,y,'-g','LineWidth',3) legend('y_1','y_2','y') xlabel('time')