I am trying to write a bit of code to solve for a system of 4 equations inside a rather large while loop, this leads to the solve() function being performed multiple times and drastically slows down the run time. Is there a way to preallocate the symbolically solved variables (so as to only input the new number) or is there a way to have matlab solve the system with matrices.
The code:
for d_t = 0:100 burn_back = d_t*5e-3; x_5 = 0.0710; x_3 = 0.4397; y_5 = 0.5487; y_3 = 0.3358;syms alpha beta x_intct y_intct; [alpha,beta,x_intct,y_intct] = solve(... x_intct == x_3 + burn_back*cos(alpha),... x_intct == x_5 + burn_back*cos(beta),... y_intct == y_3 + burn_back*sin(alpha),... y_intct == y_5 + burn_back*sin(beta),... [alpha beta x_intct y_intct]); alpha = double(alpha); beta = double(beta); x_intct = double(x_intct); y_intct = double(y_intct);end
Any help would be greatly apreciated.
Best Answer