Good Morning,
Please I have a function F = 3*a*b
Therefore how can i change (a*b) with a variable 'x' to obtain F = 3*x
Think you.
MATLABreplacevariables
Good Morning,
syms t1 t2 t3 t4 a1 a2 d3M = [cos(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)) - sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)), - cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) - sin(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)), 0, a1*cos(t1) + a2*cos(t1)*cos(t2) - a2*sin(t1)*sin(t2)cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) + sin(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)), cos(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)) - sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)), 0, a1*sin(t1) + a2*cos(t1)*sin(t2) + a2*cos(t2)*sin(t1) 0, 0, 1, d3 0, 0, 0, 1]; M_simplify = simplify(M)
>> M_simplifyM_simplify =[cos(t1 + t2 + t4), -sin(t1 + t2 + t4), 0, a2*cos(t1 + t2) + a1*cos(t1)][sin(t1 + t2 + t4), cos(t1 + t2 + t4), 0, a2*sin(t1 + t2) + a1*sin(t1)][ 0, 0, 1, d3][ 0, 0, 0, 1]
M_simplify = simplify(M, 'Seconds', 10); % specify maximum number of seconds MATLAB spent on simplification
qini = zeros(1,6); % Initial guess
ci = fsolve(@funec,qini) % fsolve with the function handle, unknown variables and initial guess
% done many variations here, none of them worked
function ec = funec(x);q1 = x(1);q2 = x(2);q3 = x(3);q4 = x(4);q5 = x(5);q6 = x(6);ec =[... sin(q6)*(cos(q1)*cos(q2)*sin(q3)*sin(q4) - cos(q4)*sin(q1) + cos(q1)*cos(q3)*sin(q2)*sin(q4)) - cos(q6)*(cos(q2 + q3)*cos(q1)*sin(q5) + cos(q5)*sin(q1)*sin(q4) + cos(q1)*cos(q2)*cos(q4)*cos(q5)*sin(q3) + cos(q1)*cos(q3)*cos(q4)*cos(q5)*sin(q2)) - 3097002709122497/18014398509481984 cos(q6)*(cos(q1)*cos(q4) + cos(q2)*sin(q1)*sin(q3)*sin(q4) + cos(q3)*sin(q1)*sin(q2)*sin(q4)) + sin(q6)*(cos(q2 + q3)*sin(q1)*sin(q5) - cos(q1)*cos(q5)*sin(q4) + cos(q2)*cos(q4)*cos(q5)*sin(q1)*sin(q3) + cos(q3)*cos(q4)*cos(q5)*sin(q1)*sin(q2)) - 6124274932042799/36028797018963968 - sin(q2 + q3)*cos(q5) - cos(q2 + q3)*cos(q4)*sin(q5) - 139701203459709/140737488355328 70*cos(q1) + 360*cos(q1)*sin(q2) - 65*sin(q1)*sin(q4)*sin(q5) + 380*cos(q1)*cos(q2)*cos(q3) - 380*cos(q1)*sin(q2)*sin(q3) + 65*cos(q1)*cos(q2)*cos(q3)*cos(q5) - 65*cos(q1)*cos(q5)*sin(q2)*sin(q3) - 65*cos(q1)*cos(q2)*cos(q4)*sin(q3)*sin(q5) - 65*cos(q1)*cos(q3)*cos(q4)*sin(q2)*sin(q5) + 19869/50 sin(q6)*(cos(q1)*cos(q4) + cos(q2)*sin(q1)*sin(q3)*sin(q4) + cos(q3)*sin(q1)*sin(q2)*sin(q4)) - cos(q6)*(cos(q2 + q3)*sin(q1)*sin(q5) - cos(q1)*cos(q5)*sin(q4) + cos(q2)*cos(q4)*cos(q5)*sin(q1)*sin(q3) + cos(q3)*cos(q4)*cos(q5)*sin(q1)*sin(q2)) + 2202239090516653/2251799813685248 cos(q2 + q3)*cos(q6)*sin(q4) - sin(q6)*(sin(q2 + q3)*sin(q5) - cos(q2 + q3)*cos(q4)*cos(q5)) + 7591943296130745/288230376151711744 cos(q2 + q3)*cos(q1)*cos(q5) - sin(q5)*(sin(q1)*sin(q4) + cos(q1)*cos(q2)*cos(q4)*sin(q3) + cos(q1)*cos(q3)*cos(q4)*sin(q2)) - 102014544375725/18014398509481984 70*sin(q1) + 360*sin(q1)*sin(q2) - 380*sin(q1)*sin(q2)*sin(q3) + 380*cos(q2)*cos(q3)*sin(q1) + 65*cos(q1)*sin(q4)*sin(q5) + 65*cos(q2)*cos(q3)*cos(q5)*sin(q1) - 65*cos(q5)*sin(q1)*sin(q2)*sin(q3) - 65*cos(q2)*cos(q4)*sin(q1)*sin(q3)*sin(q5) - 65*cos(q3)*cos(q4)*sin(q1)*sin(q2)*sin(q5) - 1563/20 cos(q6)*(sin(q2 + q3)*sin(q5) - cos(q2 + q3)*cos(q4)*cos(q5)) + cos(q2 + q3)*sin(q4)*sin(q6) - 2129854249224409/18014398509481984 cos(q6)*(cos(q1)*cos(q2)*sin(q3)*sin(q4) - cos(q4)*sin(q1) + cos(q1)*cos(q3)*sin(q2)*sin(q4)) + sin(q6)*(cos(q2 + q3)*cos(q1)*sin(q5) + cos(q5)*sin(q1)*sin(q4) + cos(q1)*cos(q2)*cos(q4)*cos(q5)*sin(q3) + cos(q1)*cos(q3)*cos(q4)*cos(q5)*sin(q2)) - 8872946535830847/9007199254740992 cos(q2 + q3)*cos(q5)*sin(q1) - sin(q5)*(cos(q2)*cos(q4)*sin(q1)*sin(q3) - cos(q1)*sin(q4) + cos(q3)*cos(q4)*sin(q1)*sin(q2)) - 8718732974408059/72057594037927936 360*cos(q2) - 380*cos(q2)*sin(q3) - 380*cos(q3)*sin(q2) - 65*cos(q2)*cos(q5)*sin(q3) - 65*cos(q3)*cos(q5)*sin(q2) - 65*cos(q2)*cos(q3)*cos(q4)*sin(q5) + 65*cos(q4)*sin(q2)*sin(q3)*sin(q5) - 39571/100];end
Best Answer