Using Perl in your MATLAB Design Flow


Anyone who designs with Matlab has probably grown tired of regenerating new script files, headers, or functions in a Matlab design. I have generated a couple of Perl Scripts that will automatically generate the script file or function files. These Perl Scripts can be invoked from within a bash terminal or a DOS Command Window. Below are the scripts: These files are hosted on GitHub at the link below:

Below are the scripts available in the GitHub MatlabTools project:

Follow MatlabTools on GitHub


How to use matlab_mod.pl?


This utility is intended to make creating new Matlab script files easier using either a bash terminal or a DOS Command window.

The script will generate the empty Matlab template for you. Note: "new_module_name.m" is the name of the new Matlab file and can be anything you like. You can either use a bash terminal or a DOS Command prompt to run this script. Instructions are provided below:

  1. Change directory to the desired directory; if necessary create a directory to store the new module.
  2.                                 [user@machine ../src] 
                                    $ mkdir top/
                                    [user@machine ../src] 
                                    $ cd top/
                                    [user@machine ../src/top] 
                                    $ 
                                
  3. Type the following: perl matlab_mod.pl new_module_name.m
  4.                                 [user@machine ../src/top] 
                                    $ perl matlab_mod.pl new_module_name.m
    
                                    The script has finished successfully! You can now use new_module_name.m.
    
                                    [user@machine ../src/top] 
                                    $ 
                                
  5. When the script is finished you will see the message: "The script has finished successfully! You can now use new_module_name.m."
Back to Top

How to use matlab_fun.pl?


This utility is intended to make creating new Matlab function files easier using either a bash terminal or a DOS Command window.

The script will generate the empty Matlab template for you. Note: "new_function_name.m" is the name of the new Matlab function file and can be anything you like. You can either use a bash terminal or a DOS Command prompt to run this script. Instructions are provided below:

  1. Change directory to the desired directory; if necessary create a directory to store the new function.
  2.                                 [user@machine ../src] 
                                    $ mkdir top/
                                    [user@machine ../src] 
                                    $ cd top/
                                    [user@machine ../src/top] 
                                    $ 
                                
  3. Type the following: perl matlab_fun.pl new_function_name.m
  4.                                 [user@machine ../src/top] 
                                    $ perl matlab_fun.pl new_function_name.m
    
                                    The script has finished successfully! You can now use new_function_name.m.
    
                                    [user@machine ../src/top] 
                                    $ 
                                
  5. When the script is finished you will see the message: "The script has finished successfully! You can now use new_function_name.m."
Back to Top