Hello. I want to solve the equation v = 0 for x, many many times, for different values of P, dd and tc. Using matlabs solve-function to find the solution takes too much time. I am trying a different approach, to avoid using the solve-function. First: Use the solve-function to find the "symbolic" expression of x. Then: Copy the equation I get and paste it into my function, hoping this will be faster. When I try to do this, (as showed bellow), I dont get the whole expression for x, because the expression is too long, and I get the message: Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display. So, my questions are: How can I get the whole expression? Or, can I use the expression I get from solve to find x, without pasting the whole expression into my function? Is there a faster way to solve this problem?
x = sym('x');P = sym('P', [3 3]);dd = sym('dd', [1 3]);tc = sym('tc', [1 3]);t2 = (tc - x)./dd;v = t2*P^-1*s^2*(P^-1).'*t2.'-1;x = solve(v,x)x = (2*P1_1^2*P2_2^2*dd1^2*dd2^2*s^2*tc3 + 2*P1_2^2*P2_1^2*dd1^2*dd2^2*s^2*tc3 + ..............more letters............... + P1_3*P2_1*P3_2 - P1_3*P2_2*P3_1)) - (P1_1*P3_3 - P1_3*P3_1)/(dd2*(P1_1*P2_2*P3_3 - P1_1*P2_3*P3_2 - P1_2*... Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display. (2*P1_1^2*P2_2^2*dd1^2*dd2^2*s^2*tc3 + .....More letters........ - (P1_1*P3_3 - P1_3*P3_1)/(dd2*(P1_1*P2_2*P3_3 - P1_1*P2_3*P3_2 - P1_2*... Output truncated. Text exceeds maximum line length of 25 000 characters for Command Window display.
It works for the two dimensional problem. I found the symbolic equation for x using solve, and pasted it into my function. The two solutions of x, xxP and xxM, are found and the equations looks like this: (Pi_j, ddi, s and tci are known)
xxP = (P1_1^2*dd1^2*s*tc2 + P1_2^2*dd2^2*s*tc1 + P2_1^2*dd1^2*s*tc2 + P2_2^2*dd2^2*s*tc1 + P1_1*P2_2*dd1*dd2*(P1_1^2*dd1^2 - 2*P1_1*P1_2*dd1*dd2 + P1_2^2*dd2^2 + P2_1^2*dd1^2 - 2*P2_1*P2_2*dd1*dd2 + P2_2^2*dd2^2 - s^2*tc1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