% 6.003: Signals and Systems - Spring '97 % S97Less5.M Lesson 5 of MATLAB MiniCourse Demonstration script % by Pat Kreidl %%%%% Illustrative Example -- Parallel RLC Circuit !clear type 5.txt pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear type problem.txt pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% echo on % Outline of Solution: We will first demonstrate how to create a % specialized function and script (using M-files) % involving the already familiar commands given in the % Basic Note. This solution method requires that we % first obtain the analytical solution of the step % response in our circuit. % % Then, we will make use of MATLAB's Help features to % learn about the currently unfamiliar, yet very powerful % commands given in the Advanced Note. We will % create another script (M-file) that uses these advanced % commands, and see that we will have saved ourselves % a significant amount of work because we will not % require grinding through the analytical solution! pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear %%%%% Basic Solution % % The approach we take here is to define a MATLAB function which takes as % inputs values for R, L, C, and T and gives the corresponding step response % as the output. This function we will call rlcstep.m The equations in % this file come from the analytical solution (consult the Lesson 5 % supplementary handout). % Then, we write a MATLAB script rlc1.m which calls on function % rlcstep.m for each of the three cases, and includes the necessary plot % commands. % % NOTE: While studying this solution, we will also be introduced to MATLAB's % C language-based "control flow" operations (e.g., if-elseif-else % conditional statements, while loops, for loops, etc.). pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear type rlcstep.m %View the MATLAB function M-file pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %NOTICE: 1) Function header line (distinguishes function from script) % 2) Help section (the many rows of commented lines at top of file) % 3) Use of an if-elseif-else statement % 4) Included in-line comments for future reference pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear %The comments section after the function header is the help rlcstep %help information! pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear rlc1 %Run MATLAB script file pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear !clear %%%%% Advanced Solution % % The approach we take here is to rely on the powerful functions given in % the advanced note of the problem statement. The first step is to use % MATLAB's Help features to learn exactly how these functions work. Then, % we write a MATLAB script rlc2.m which calls on these functions for % each of the three cases. These functions will allow us to determine % the form of the step response, in addition to plotting them, without % relying on the analytical solutions! pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear help residue %Learn about function residue pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear help step %Learn about function step pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !clear rlc2 %Run MATLAB script file pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% echo off close clear