How can I create a symbolic vector of functions that dsolve will recognize as variable dependent functions. Need to do this in order to symbolically solve a system of ODEs.
2 views (last 30 days)
Show older comments
I understand that to create individual time or space dependent functions, I can do the following:
syms V1(z) V2(z) V3(z) ...etc
However, I do not know in advance how many of these symbolic functions/variables I will need to create. Instead, the number of space dependent functions I will need depends on the size of a 2D square matrix that is passed to my function. Therefore, I cannot hard code the functions like I have above.
An example of what I am trying to solve:
S1 = dsolve(diff(V1(x),2) == V1(x))
S1 = dsolve(diff(V2(x),2) == V2(x))
S1 = dsolve(diff(V3(x),2) == V3(x))
S1 = dsolve(diff(V4(x),2) == V4(x))
S1 = dsolve(diff(V5(x),2) == V5(x))
I don't use the ode solver because neither do I know the boundary conditions nor do my equations vary as a function of time. Additionally, I have already tried the following:
N = 5; %Assume size of input matrix is 5x5 for illustration purposes
V = sym(zeros(1,N)); % Not necessary, just much faster
V(i) = sym(sprintf('V%d(x)', i)); % some equation
S = dsolve(diff(V(1),2) == V(1))
However, I get this error:
Error using symengine (line 58) Could not extract differential variables to solve for. Use 'solve' or 'vpasolve' to compute the solutions of non-differential equations.
Note: I am trying to avoid vpasolve like the plague
Thanks in advance,
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!