% Program 5.8 % RR robot arm % Dynamics % Newton-Euler equations of motion % the program uses the function: RRrobot(t,x) % the function is defined in the program RRrobot.m clear; clc; close; t0 = 0; tf = 10; time = [0; tf]; x0 = [-pi/18; 0; pi/6; 0]; [t,xs] = ode45(@RRrobot, time, x0); x1 = xs(:,1); x2 = xs(:,2); x3 = xs(:,3); x4 = xs(:,4); subplot(2,1,1),plot(t,x1*180/pi,'r'),... xlabel('t (s)'),ylabel('q1 (deg)'),grid,... subplot(2,1,2),plot(t,x3*180/pi,'b'),... xlabel('t (s)'),ylabel('q2 (deg)'),grid % [ts,xs] = ode45(g,0:1:5,x0); % [ts,xs]