MATLAB: How to solve three equations for four unknowns

four equations and three unknowns

My four equations are as follows:
x1_temp(t) == exp(-t*theta1_temp)*u1(t);
x2_temp(t)= y-gamma;
x2_temp(t) == exp(-t*theta2_temp)*(theta1_temp*x1_temp(t) + 1160917147506309/70368744177664)
Here, the unknowns are theta1_temp, theta2_temp, x1_temp(t), x2_temp(t). Other all are known. Please suggest a way to solve this problem. Thanks in advance for the help.

Best Answer

You can only solve for three out of the four variables.
syms x1t t t1t u1 x2t y gamma t2t
eq = [ x1t == exp(-t*t1t)*u1, x2t==y-gamma, x2t == exp(-t*t2t)*(t1t*x1t+1160917147506309/70368744177664)]
sol = solve(eq, [t1t, t2t, x2t], 'returnconditions',true)
You will find that the result is parameterized in two variables, and that the "conditions" returned is mostly that the two variables are each integer. What that is saying is that there are an infinite number of solutions that differ by multiples of 2*pi*1i
If you are willing to restrict to real values, then add the word "real" at the end of the syms line. sol would then have exactly one set of solutions.
Note that asking to solve for [t1t, t2t, x1t] will not return back any values.
If you ask to solve for [t1t, x1t, x2t] assuming real values, then you will get back three solution sets. The solutions will involve different branches of the Lambert W function. After you have substituted in the known values and have substituted in t and u1, you might find that some of the solutions turn out to be complex valued.