symsofequation
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Symbolics tools
Introduced first in SolidGeometry 4.8, Creation date: 2019-11-11, Last change: 2025-09-14
returns or defines the symbols of a equation system
Description
if there is no output, the symbols are defined using evalin('caller',ev) in the calling workspace
See Also:
Example Illustration
Syntax
[S,v,ev]=symsofequation([eq])
Input Parameter
eq: | | equation systems to analyze |
Output Parameter
S: | | String of Symbols |
v: | | cell list of Symbols |
ev: | | evaluation string |
Examples
symsofequation('U==R*I, P==U*I, W==P*t');
Copyright 2019-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)
The function symsofequation is designed to analyze a system of equations and identify the symbols used within them. It is part of the SYMBOLICS TOOLS class in the SG-Library.
Input Parameters
- eq: A string representing the equation system to be analyzed. If not provided, it defaults to
'U==R*I, P==U*I, W==P*t'.
Output Results
- S: A string containing all the symbols found in the equation system, separated by spaces.
- v: A cell array listing each symbol individually.
- ev: A string formatted for evaluation, which declares the symbols using the
syms command.
Algorithm Steps
- The function begins by retrieving the equation system from the input parameters using
getfuncparams. If no input is provided, it uses the default equation.
- It identifies the symbols in the equation using the
symvar function, storing them in the variable v.
- An empty string
S is initialized to accumulate the symbols.
- A loop iterates over each symbol in
v, appending it to S with a space separator.
- The trailing space in
S is removed using strtrim.
- The evaluation string
ev is constructed using sprintf to format the syms command with the symbols in S.
- If no output arguments are specified, the function prints the evaluation string and executes it in the caller's workspace using
evalin.
Example
Calling symsofequation('U==R*I, P==U*I, W==P*t') will identify the symbols U, R, I, P, W, and t, and construct the evaluation string 'syms U R I P W t'.
Algorithm explaination created using ChatGPT on 2025-08-18 23:38. (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