Creating an array of dependent symbolic variable
Mostrar comentarios más antiguos
Hi,
I need to create 'N' equations based on user input 'N' which is a natural number.
Each equation is supposed to have a variable A which is a dependent on x. This 'A' term is different for each equation. Equation1 will have A1, equation2 will have A2 and so on.
I am creating this term using the expresion below.
A = sym('A', [1 N]);
This gives me symbolic variables A1, A2, A3... AN. But the problem is these terms are just symbolic variables and not dependent on x. So if I differentiate the equation with respect to x, these terms dissappear. If I use A(x) to create the variable (like a normal dependent variable), it returns a 1x1 symbolic function instead of 1xN symbolic variables.
A(x) = sym('A', [1 N]);
The above equation creates 1xN symbolic variables but the output is of type 1x1 symbolic function. Is there a way to isolate each term from this function or is there any other way to create a dependent variable array.
Thanks
2 comentarios
madhan ravi
el 13 de Oct. de 2020
What’s your application by your idea?
Abinav
el 13 de Oct. de 2020
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 13 de Oct. de 2020
syms A [1 2]
eq1 = A(1)+2*A(2) == 42
eq2 = 3*A(1)-4*A(2) == 99
S = solve(eq1, eq2)
A1 = S.A1
A2 = S.A2
subs(eq1)
1 comentario
Abinav
el 13 de Oct. de 2020
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!