Skip to content

Developing Functions

Stephen Frank edited this page Nov 18, 2013 · 4 revisions

Developing Functions

All MATLAB utility functions are located within the Library/ directory in one of several subdirectories:

  • utility/ contains general utility functions
  • ssc2matlab/ contains functions which extend the MATLAB interface of SSC
  • databus2matlab/ contains functions which provide a MATLAB interface to DataBus

Code

Creating New Functions

If your new function belongs to a new category, you must first create a category subdirectory for it under Library/:

  1. Create the category subdirectory. Use a lowercase name for consistency with the other categories.
  2. Add the new subdirectory to your MATLAB path.
  3. Verify that the project installation script, install.m, will detect and install the subdirectory when run. This should happen automatically.
  4. Commit your changes (if you haven't already).
  5. If the category will be merged into an official version of the Campus Energy Modeling project, then also add the new subdirectory to the list at the top of this wiki page.

Once a category exists for your function, follow these steps to add the function to the project:

  1. Write and test your function. For assistance, see Function Basics in the MATLAB documentation.
  2. Document your function using the guidelines and template provided in Writing Documentation.
  3. Place the .m script which contains your function in the appropriate category subdirectory under Library/.
  4. Commit your changes (if you haven't already).
  5. Consider also creating an automated test script for your new function.

Existing utility functions provide excellent examples for both code style and documentation.

Modifying Existing Functions

If you modify an existing function, please update the function documentation as needed. If applicable, please also update any tests and demos which use the function.

Documentation

Please document your function as described in Writing Documentation.

Once your function is included with an official release of the Campus Energy Modeling project, you should also update the wiki documentation:

  • For new utility function categories, add a section and description to Utility Functions.
  • For new utility functions, add an entry under the appropriate section of Utility Functions.
  • For modified utility functions, update the function entry in Utility Functions as needed.

Clone this wiki locally