ENG 6 Lecture Notes - Lecture 7: Inline Function, Systemc, Empty String
Document Summary
Concept: procedural abstraction: permits a code block that solves a particular sub problem to be packaged and applied to different data inputs. Concept: encapsulation: putting a wrapper around a collection you want to protect from outside influence, encapsulate code in 2 ways: Variables declared within function are not visible from outside. Functions can only change values of variables within its own code body. Don t confuse scripts with functions: m-file scripts: Sequential execution of commands, top to bottom. Can be called by other m-file scripts. No passing of variables as arguments; when called. Function as a black box: parameters: formal parameters are names given to incoming data in function. are actual parameters provided to function. May have names different from formal parameter. Correlated to formal parameter names by position. Function elements to be returned are identified. Function name should correspond to m-file name. First line format for m-file function_name. m: function [ret1, ret2] = function_name(a1,a2)