?? robot.m
字號:
function robot% ROBOT Example for usage of newton method : Robot arm, two% dimensional, two arms. Type 'robot' to start. % Author : Andreas Klimke, Universit鋞 Stuttgart% Version: 1.0 % Date: June 13, 2003 % Define robot arm lengthsl = [4; 2];% Set the target pointp = [3; 4];% Perform newton iteration[x, niter] = newtonsys(@f_robot, [pi/2; pi/2], 1e-5, 20, l, p) % Display resultsdisp(['Result: alpha = ' num2str(x(1)/pi*180)]);disp([' beta = ' num2str(x(2)/pi*180)]);% Visualize the solutiony = [0, 0; ... l(1)*cos(x(1)), l(1)*sin(x(1)); ... l(1)*cos(x(1))-l(2)*cos(x(1)+x(2)), l(1)*sin(x(1))-l(2)* ... sin(x(1)+x(2))]; plot(y(:,1), y(:,2), '-o', 'LineWidth', 2);text(0.4, 0.4, '\alpha','FontSize',16);text(y(2,1)+0.2, y(2,2)-0.3, '\beta','FontSize',16);axis([-2,5,0,6])grid% ---------------------------------------------------------------function out = f_robot(x, flag, l, p)% Definition of the two-dimensional function if isempty(flag) flag = '';end switch lower(flag) case '' out = [l(1)*cos(x(1))-l(2)*cos(x(1)+x(2))-p(1); ... l(1)*sin(x(1))-l(2)*sin(x(1)+x(2))-p(2)]; case 'jacobian' out = [-l(1)*sin(x(1))+l(2)*sin(x(1)+x(2)), ... l(2)*sin(x(1)+x(2)); ... l(1)*cos(x(1))+l(2)*cos(x(1)+x(2)), ... -l(2)*cos(x(1)+x(2))];end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -