Syntax
evalTLvars(DEFPAR,TLPAR)
Input Parameter
DEFPAR : | | Default variable values |
TLPAR : | | Parameter string (varargins) to overload the default values |
Examples
Create variables by a string:
evalTLvars ('a=12, b=13, c=a+b', varargin{1});
Copyright 2015-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This algorithm is designed to modify or create variables in the workspace of the calling procedure by evaluating strings containing default parameter values and optional overriding parameters.
Input Parameters
- DEFPAR: A string containing default variable values, formatted as assignments (e.g., 'a=12, b=13').
- TLPAR: A string containing additional parameters that can override the default values specified in DEFPAR.
Algorithm Steps
- Concatenate a semicolon to the end of DEFPAR to ensure proper separation of statements.
- Concatenate DEFPAR and TLPAR to form a single string that contains both default and overriding parameters.
- Split the concatenated string into individual statements using commas and semicolons as delimiters. This results in a cell array of parameter assignments.
- Iterate over each element in the cell array:
- For each element, use the
evalin
function to evaluate the statement in the context of the caller's workspace. This creates or modifies the variables as specified by the statement.
- Remove duplicate parameter assignments by reversing the order of the split strings, applying the
unique
function with the 'stable' option, and then reversing the order again. This ensures that the last occurrence of each parameter is retained.
- Join the unique parameter assignments back into a single string, separated by semicolons, and return this as the modified TLPAR.
Algorithm explaination created using ChatGPT on 2025-08-19 00:02. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21