# Solving a simple vectorial equation with one unknown

4 views (last 30 days)
Carlos Acasuso on 5 Jan 2021
Edited: Bruno Luong on 5 Jan 2021
Hello,
I would like to ask for help with the following case. I have a vectorial equation where there is a cross product, and the unknown 'x' is within the cross product.
The equation is simply the cross product between two vectors, which is equal to the torque being applied to a rotating system.
The code is the following:
P = [126.7611; -118.5356; 331.2583]; % Point P, at which force is applied
A = [161.0000; -118.5258; 323.7618]; % Point A on axis of rotation
AB = [0; 1.0000; -0.0005]; % AB Unit Vector of axis around which torque is applied
CD = [-0.0438; -0.2179; -0.9750]; % CD Unit Vector of droplink
T = [0; -4806.2; 0]; % Torque Magnitude
% Find AP, AP = P-A
AP = P - A;
% Find point O, projection of P on AB
O = A + dot(AP,AB) * AB;
% Find Vector OP, OP = P-O
OP = P - O;
% State Equation to solve:
% Actual equation is: T = cross(OP,x*CD)
f = @(x)[cross(OP,x*CD) - T];
xSol = fsolve(f, 0, opts);
My question is whether this is the correct way of solving this equation, and also why am I getting the following error when the code is executed:
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.
C

Bruno Luong on 5 Jan 2021
Edited: Bruno Luong on 5 Jan 2021
fsolve requires the number of unknowns == number of equations.
This is the least-square solution
f = @(x)norm([cross(OP,x*CD) - T])^2;
xSol = fsolve(f, 0)
Or you can just compute directly without using any fancy solver
x = T.'/cross(OP,CD).'
##### 2 CommentsShowHide 1 older comment
Bruno Luong on 5 Jan 2021
This is warning, since the least square solution does not make the solution to exactly match T. Normal: your T is not perpendicular to OP and CD and cannot be written as they cross product.

R2019b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!