g=subsvar(f,sv,[])
f : | original term / equation | |
sv : | array of symbols to substitute or [s1 v1; s2 z2]; |
g : | resulting term / equation |
syms x(t) D C F m; dx=diff(x); ddx=diff(x,2);
f=dsolve(m*ddx+D*dx==0, x(0)==0,x(6)==1); sv=symvar(f)
subsvar(f,[D m],[1 1])
subsvar(f,[D 1;m 1])
This function, subsvar
, is designed to substitute multiple symbols or terms in a symbolic equation. It is part of the SYMBOLICS TOOLS class and was introduced in SolidGeometry 4.2.
sv
.nv
.nv
.sv
is a matrix with symbols in the first column and values in the second. Assign these to sv
and nv
respectively.g
with the original equation f
.sv
and substitute it with the corresponding value in nv
using the subs
function.nargout==0
), display the result in a pretty format.Consider the following example where syms x(t) D C F m;
defines symbolic variables and dx=diff(x); ddx=diff(x,2);
defines derivatives. The function dsolve
is used to solve a differential equation, and subsvar
is used to substitute values for D
and m
.
Example code:
syms x(t) D C F m; dx=diff(x); ddx=diff(x,2); f=dsolve(m*ddx+D*dx==0, x(0)==0,x(6)==1); sv=symvar(f); subsvar(f,[D m],[1 1]); subsvar(f,[D 1;m 1]);Algorithm explaination created using ChatGPT on 2025-08-19 00:12. (Please note: No guarantee for the correctness of this explanation)