Experiment 3 : User defined function (3 marks) An important feature of the MATLAB environment is that it permits us to c
Posted: Fri Apr 29, 2022 8:50 am
Experiment 3 : User defined function (3 marks) An important feature of the MATLAB environment is that it permits us to create our own M-files or subroutines. Two types of M-files exist, namely, scripts and functions. Scripts, or script files, automate long sequences of commands. On the other hand, functions, or function files, provide extensibility to MATLAB by allowing us to add new functions. Any variables used in function files do not remain in memory. For this reason, input and output variables must be declared explicitly. We may thus say that a function M-file is a separate entity characterized as follows: 1. It begins with a statement defining the function name, its input arguments, and its output arguments. 2. It also includes additional statements that compute the values to be returned. 3. The inputs may be scalars, vectors, or matrices. Write a user defined function for the following: - Input to the function: vector of size of 1 by L, where I can be from 1 to o. The function is to process equation x(t) = 10e-4 – 5e -0.5t Output of the function: vector of size of 1 by L Define an input in another m file and call the defined function to display the output. (Note: you can choose your own values of input. i.e. 1:0.01:5).