A blog to help electrical engineers and students to learn electrical engineering topics. Basic Electrical Engineering, Power Systems, Electrical Machines, tec.. Now special course on MATLAB for Beginners.

Class

Class

Thursday, December 1, 2016

User Defined Functions in MATLAB - Part 1

User-defined functions are similar to the MATLAB predefined functions. A function is a MATLAB program that can accept inputs and produce outputs. A function can be called or executed by another program or function. Code for a function is done in an Editor window or any text editor same way as script and saved as m-file. The m-file must have the same name as the function.

It is important that you give meaningful variable names to variables inside a function that you write, so that you and others can understand what the function does. The function M-file must be saved in your current directory.


The declaration statement 'function' is used to define the file as a function. It must be typed in lower case letters. Rules for giving function name is same as the rules for variable names.
Input arguments are typed in side the parentheses ( ). They are used to transfer data into function from calling program. Can be zero or more input arguments. 
Output arguments are typed inside the square brackets [ ]. They are used to transfer data out of function to calling program. Can be zero or more output arguments. It is important to give a meaningful variable names.

submit to reddit

4 comments:

  1. Get an individual relating to seeking myself to many established that will benevolents professional dint functionality parts. My partner and i perform obtained sag sage ease relating to attain impromptu classs My partner and i brighter frequented. Amidst that will unparalleled, We're confident connected with reduce short-term. satellite repair in kuwait

    ReplyDelete
  2. Thank You for the information , you can learn more about Basic Electrical Engineering

    ReplyDelete
  3. Get more information on this from top learning apps online for engineering!

    ReplyDelete
  4. Ekeeda Provides Online Video Lectures, Tutorials & Engineering Courses Available for Top-Tier Universities in India. Lectures from Highly Trained & Experienced Faculty! Checkout Best engineering courses

    ReplyDelete