Today is: Thursday April 25, 2024
How to use 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 VI/VIM/GVIM, or a DOS Command Window. Below are the scripts:
- matlab_mod.pl : Matlab Script File Template Creation Perl Script [download]
- matlab_fun.pl : Matlab Function File Template Creation Perl Script [download]
How to use matlab_mod.pl?
This utility is intended to make creating new Matlab script files easier using either
a good editor; such as VI, or a DOS Command window. As long as you set the top line
to correctly point to your perl binary, and place this script in a directory in your
path, you can invoke it from within VI. Simply use the !! command and call this script
with the filename you wish to instantiate. This script will create a new text file called
"new_module_name.m" when you type the following command:
!! matlab_mod.pl new_module_name.m
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 VI or a
DOS Command prompt to run this script. If you want to use a DOS Command prompt, then see
the instructions below:
- Change directory to the desired directory
- cd C:\design\new_module
- If the directory "new_module" does not exist type: mkdir C:\design\new_module, before changing directory.
- Type the following: perl matlab_mod.pl new_module_name.m
- When the script is finished you will see the message: "The script has finished successfully! You can now use new_module_name.m."
How to use matlab_fun.pl?
This utility is intended to make creating new Matlab function files easier using either
a good editor; such as VI, or a DOS Command window. As long as you set the top line
to correctly point to your perl binary, and place this script in a directory in your
path, you can invoke it from within VI. Simply use the !! command and call this script
with the filename you wish to instantiate. This script will create a new text file called
"new_module_name.m" when you type the following command:
!! matlab_fun.pl new_function_name.m
The script will generate the empty Matlab function 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 VI or a
DOS Command prompt to run this script. If you want to use a DOS Command prompt, then see
the instructions below:
- Change directory to the desired directory
- cd C:\design\new_function
- If the directory "new_function" does not exist type: mkdir C:\design\new_function, before changing directory.
- Type the following: perl matlab_mod.pl new_function_name.m
- When the script is finished you will see the message: "The script has finished successfully! You can now use new_function_name.m."
Jeremy W. Webb
Last Modified: Thursday, March 23, 2017 08:07:13 PM