Hello,
I am trying to solve a symbolic system of equations that I automatically generate based on user data. The coefficients and the size of the system can change.
Here is an example of code for a 2×2 system :
————————–
eps1 = 1;eps2 = 1;eps = [eps1;eps2];sigma = 1;k = ones(2,1);h=[1;1];Tw = sym(zeros(2, 1));for i=1:2 Tw(i) = sym(sprintf('Tw%d', i));endf = -sigma*eps.*Tw.^4;Jacf = jacobian(f,Tw);Tw0 = [293;293];A = subs(Jacf,Tw,Tw0);c = subs(f,Tw,Tw0)-A*Tw0;T = sym(ones(2, 1));T(1) = sym('To');T(2) = sym('Ti');S = sym(ones(2, 1));for i=1:2 S(i) = sym(sprintf('S%d', i));endG = S+h.*(T-Tw)+c+A*T;solve(G,Tw);
————————-
The system is obtained through linearisation of expression f. I would like to obtain Tw as an expression depending on T and S. But when I try to solve for G == 0, the solver solves in T and Tw instead of only Tw…
If I use solve(G,Tw(1),Tw(2)) then I get the good answer, but as the system is of arbitrary size in the general case, I don't know how to adapt this expression to get an answer.
Any idea how to fix this ?
Thanks,
Tomasz
Best Answer