To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I'm trying to use Fsolve to convert 5 data inputs into 5 data outputs. I've tried the pen-and-paper method, and it's beyond my meager abilities to derive explicit formulae, so I need MATLAB to do it for me.
Basically, I have 5 equations, 5 outputs, and 5 sensor inputs that would serve as constants, repeated up to 400 time points. If inputs are x and outputs y, general format would be:
So for each timepoint, I would like to use actual sensor readings to put real numbers in for X1 through X5, then find the values for Y1 through Y5 with fsolve inside a For loop.
Problem is, I can't figure out how the inputs and such would work, and how to handle "constants that vary within a loop" (I'm sure there's a real term I don't know). I know fsolve wants me to write a function, but if I feed that function all 10 inputs, how will Fsolve know which ones to solve for and which ones need to remain constant? I have no code to post because I am completely flumoxed - I can't even begin to think of how to do this.
Short version: I need fsolve to solve a system of 5 equations over and over again with 5 different constants each time. I know fsolve wants me to write a function, but if I give that function all 10 inputs (guesses + constants), how will Fsolve know which ones to solve for and which ones need to remain constant?
No products are associated with this question.
However, it doesn't look like FSOLVE is the appropriate tool here. Your equalities are all linear in Y, so the solution space should be given by A\b where the matrix A and vector b are derived from the Xi
You did not specify which variables to solve for, so solve() used its own ideas about which to use and those did not match your expectations. Specify the variables yourself:
syms Fsx, Fsy, Fx, Fy, Fz, Msx, Msy, Msz, Tz, xoff, yoff, zoff [Fx,Fy,xoff,yoff,Tz] = solve(Fx-Tz*yoff-Fsx, Fy-Tz*xoff-Fsy, Fy*zoff-Fz*yoff-Msx, Fz*xoff-Fx*zoff-Msy, Fx*yoff-Fy*xoff-Msz, Fx, Fy, xoff, yoff, Tz);
You might find that the solutions are all expressed as multiples of an expression involving a RootOf() term. That RootOf() term will be a way of expressing that at that point you should substitute the two solutions to a quadratic function,
The RootOf() represents the roots, the set of values of Z such that the expression in the first term becomes 0. There is, of course, an analytic form of that, but it would be messy to write.
If you extract the RootOf() term using op(), then you can subs() another variable name (e.g., "R") for the expression in each of the formulas you got, in order to give you pretty compact representations of those formulas. That is not necessary, but it can make things much easier to understand. But from there through the rest of your program you need to keep in mind that each of the variables you calculated has two values, one corresponding to each of the two roots.