echo on % This script will plot a series of functions of the % form c1*exp(lam1*t) + c2*exp(lam2*t) + ... c10*exp(lam10*t) % where c1 to c10 are randomly chosen between -2.5 and 2.5 % and lam1 to lam10 are complex roots whos real parts are % randomly chosen between -2 and 0, and the imaginary parts are % chosen between 1 and 4. % The plot will be displayed until a key is struck on the % keyboard. t = [0:.1:10]; % Define Time Axis for function evaluation % Loop through 10 different functions for k=1:10 cr = 5*(rand(1,5) - .5); % Randomly pick 5 complex coefficients ci = 5*(rand(1,5) - .5); c = [(cr+j*ci), (cr-j*ci)]; subplot(3,1,1), plot(abs(c)) % Plot out magnitudes ylabel('Coefficent Magnitudes') lamr = -2*rand(1,5); % Randomly pick 10 complex frequenies lami = 1 + 3*rand(1,5); lam = [(lamr+j*lami), (lamr-j*lami)]; subplot(3,1,2), plot(abs(lam)) % Plot out magnitudes ylabel('Time Constant Magnitudes') subplot(3,1,3), plot(t, real(c*exp(lam'*t))) % Evaluate and plot function ylabel('Function') xlabel('seconds') pause % Hold figure until Key is struck end echo off