Table of Contents
qc_build_script
Builds a MATLAB script for a target.
qc_build_script(script, target_type, flag, ...) % Builds a script for the given target with flag qc_build_script(script, target_type, ...) % Builds a script for the given target qc_build_script(script, flag, ...) % Builds a script for the default target or target identified by the extension with flag qc_build_script(script, ...) % Builds a script for the default target or target identified by the extension
Builds a script for a target. This function automatically generates a build script and main C file if necessary. If either of these generated files already exists it does not overwrite them unless the flag argument is 'overwrite'. Hence, the build script and main C file may be modified after they are created.
To update the target type without otherwise modifying the build script, use the 'update' flag. The full set of flags is listed below:
Flag |
Description |
---|---|
'overwrite' |
Overwrite the generated build script and main C file with new ones based on the script name and requested target type. The script executable is then built using the newly generated code. |
'update' |
Update the build script, if it exists, to generate code for the requested target type. Only the toolchain in the build script is modified to match the target type. The script executable is then built using the updated build script. |
'overwrite_only' |
Overwrite the generated build script and main C file with new ones based on the script name and requested target type. The script executable is not built. |
'update_only' |
Update the build script, if it exists, to generate code for the requested target type. Only the toolchain in the build script is modified to match the target type. The script executable is not built. |
'gen_only' |
Generate the build script and main C file if they do not exist. Do not build the script executable. |
The build script will be named script_build.m, where script is the name of the script. The main C file will be called script_main.c.
The extra parameters are used for defining any arguments to the generated code. The format of arguments should be a name, preceded by a hyphen, as a string and a default value that matches the type of the argument. For example, to define a double argument called '-gain' and an integer option called '-select', the parameters would be defined as follows:
qc_build_script('myscript', '-gain', 5, '-select', int32(2));
Note that these arguments MUST appear in the same order as the parameters to the script and have the same data types. The names of the arguments, however, do not have to match. There must be one argument for each parameter of the script for which code is being built.
Both scalar and vector values are supported.
For string arguments, the length of the value determines the length of the string supported, so append null characters to the value if necessary to set the maximum string length. For example, to extend the string 'hello' to 30 characters, do:
['hello', char(zeros(1,25))]
When running the script, the arguments are passed as a string. For the same example as above, for instance:
qc_run_script myscript.rt-win64 -gain 2 -select 0
or alternatively:
qc_run_script('myscript.rt-win64', '-gain', '2', '-select', '0');
If an option is not specified then it will take on the default value specified when qc_build_script was called.
To pass a variable value as an argument, be sure to convert the value
to a string. For example, to use the values of the variables Kp
and opt
, the command would be:
qc_run_script('myscript.rt-win64', '-gain', num2str(Kp), '-select', num2str(opt));
Vector values are passed with spaces separating each element. For example:
qc_run_script myscript.rt-win64 -gain 7.2 1.6 3.9
Note that num2str can thus be used for the vector value just as it can with a scalar, as above.
script
A string indicating the name of the script. eg. 'myscript'. If the script name is given a QUARC executable extension, such as .rt-win64, then the extension determines the target type, unless a target type argument is given.
target_type
A string containing the type of target e.g. 'win64'
flag
One of the following strings: overwrite, update, overwrite_only, update_only or gen_only. See the description above for more details.
...
A name, value pair for each parameter of the script for which code is being generated, in order. The name must be a string beginning with a hyphen e.g. '-gain'. The value will be used as the default value for the parameter and must match the data type of the corresponding script argument.
This function has no outputs.
qc_build_script('myscript'); % Builds the myscript.m script as real-time code for the default target qc_build_script('myscript.rt-win64'); % Builds the myscript.m script as real-time code for the QUARC Win64 target
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.