symfun2sym

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Symbolics tools
Introduced first in SolidGeometry 1.1, Creation date: 2013-09-17, Last change: 2025-09-14

converts a symfun into a sym (=command formula)

Description

Same as matlab command: formula: Anyway you can learn something by reading it. Function is existing in matlab already. This function is required if a symbolic equation matrix should be separated into individual elements. In this case F(1,1) describes row/column instead of function parameters

Example Illustration

 missing image of symfun2sym(AF)

Syntax

[AS,a]=symfun2sym(AF)

Input Parameter

AF: symbolic function

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

Output Results

Algorithm Steps

  1. Retrieve the argument names of the symbolic function AF using argnames(AF) and store them in a.
  2. Determine the number of arguments k by calculating the length of a.
  3. Convert the argument names to a character array sa using char(a).
  4. 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.
  5. Replace commas in sa with spaces to prepare it for symbolic variable declaration.
  6. Declare the symbolic variables using eval(sprintf('syms %s', sb)), where sb is the modified string of argument names.
  7. 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