Syntax
[AS,a]=symfun2sym(AF)
Input Parameter
Output Parameter
AS : | | symbol separated function |
a : | | argnames |
Examples
syms R(w);
R(w)=[cos(w) -sin(w) 0 0;sin(w) cos(w) 0 0; 0 0 1 20+w; 0 0 0 1]
F=R, F(2)
F=symfun2sym(R),F(3,4)
Copyright 2013-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 convert a symbolic function (symfun) into a symbolic expression (sym). It is particularly useful when dealing with symbolic equation matrices that need to be separated into individual elements.
Input Parameters
- AF: A symbolic function that you want to convert into a symbolic expression.
Output Results
- AS: The symbolic expression obtained from the symbolic function.
- a: The argument names of the symbolic function.
Algorithm Steps
- Retrieve the argument names of the symbolic function
AF
using argnames(AF)
and store them in a
.
- Determine the number of arguments
k
by calculating the length of a
.
- Convert the argument names to a character array
sa
using char(a)
.
- If there is more than one argument, adjust
sa
to remove unnecessary characters by slicing the string from the 10th character to the third last character.
- Replace commas in
sa
with spaces to prepare it for symbolic variable declaration.
- Declare the symbolic variables using
eval(sprintf('syms %s', sb))
, where sb
is the modified string of argument names.
- Evaluate the symbolic function
AF
with its arguments to obtain the symbolic expression AS
using eval(sprintf('AS=AF(%s);', sa))
.
Example
Consider a symbolic function R(w)
defined as a matrix:
syms R(w);
R(w) = [cos(w) -sin(w) 0 0; sin(w) cos(w) 0 0; 0 0 1 20+w; 0 0 0 1];
To convert this symbolic function into a symbolic expression, use:
F = symfun2sym(R);
Now, F
can be used to access individual elements of the matrix, such as F(3,4)
.
Algorithm explaination created using ChatGPT on 2025-08-18 23:39. (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