MATLAB: Any ideas why when I try to plot this RRR robot on Matlab I kept getting an error stating ” A numeric or double convertible argument is expected”

robot simultation

clear
clc
%syms d1 a1 a2 a3 real
syms th1 th2 th3 real
syms Nx Ny Nz Ox Oy Oz Ax Ay Az Px Py Pz real % equal the forward transformation T03
syms C1 C2 C3 S1 S2 S3 a1 a2 a3 d1 real
%COS SIN SIMPLIFICATION
C12=C1*C2-S1*S2;
S12=S1*C2+C1*S2;
C23=C2*C3-S2*S3;
S23=S2*C3+S3*C2;
% KT contains link length of the RRR robot
d1 = 15;
a2= 26;
a3 = 6
KT=([th1 d1 0 -pi/2; th2 0 a2 0; th3 0 a3 0; 0 0 0 1])
% Tranformation Matrices
T01=Tranf(KT(1,:))
T12=Tranf(KT(2,:))
T23=Tranf(KT(3,:))
T03=T01*T12*T23
%VERIFIED FROM KT TEST
T01s=[C1 0 -S1 0; S1 0 C1 0; 0 -1 0 d1; 0 0 0 1];
T12s=[C2 -S2 0 a2*C2; S2 C2 0 a2*S2; 0 0 1 0; 0 0 0 1];
T23s=[C3 -S3 0 a3*C3; S3 C3 0 a3*S3; 0 0 1 0; 0 0 0 1];
T03s=T01s*T12s*T23s
%Displacement Vector
m=50; %Number of points (+1)
%px has decrement of 2
x=350:-100/m:250;
%py has increment of 5
y=-125:250/m:125;
%pz has increment of 7
z=-150:350/m:200;
%Multiply both sides of the equation to remove th1 from the unknown on the
%right
T0103 = inv(T01)*T03s
Tfirst = inv(T01s)*T01s*T12s*T23s
%Known values.Represents the desired configuration of tool
nx = 0;ny = 0;nz = 1;
ox = 0;oy = -1;oz = 0;
ax = 1;ay = 0;az = 0;
px = 0;py = 0;pz = 0;
%NOAPSfirst is equal to T0103
NOAP=[nx ox ax px; ny oy ay py; nz oz az pz; 0 0 0 1];
NOAPS=[Nx Ox Ax Px; Ny Oy Ay Py; Nz Oz Az Pz; 0 0 0 1];
NOAPfirst=inv(T01s)*NOAPS;
%Allocating space for theta matrix calculation
th1 = zeros(m+1,1); % 51 rows and 1 column all rows are zero
th2 = zeros(m+1,1);
th3 = zeros(m+1,1);
th23 = zeros(m+1,1);
for i=1:m+1 % i ranges from 1 to 51
px=x(i); %Known values. Position of the tool. This matrix plus the matrix on line 41 is equivalent to T03 (forward transformation matrix)
py=y(i);
pz=z(i);
th1(i,:) = atan2(py,px); %First joint angle. This can sometimes be calculated directly from the forward transformation by using tan(inv) of py/px. Caution! Use ATAN2 (py,px) instead.
%th23 = atan2(-cos(t1(i,:))*ax-sin(t1(i,:))*ay,-az);
th2(i,:) = atan2(((ay*sin(th1(i,:)))/cos(th1(i,:)))+(ax)+(sin(th1(i,:))),(ay)-((ax*sin(th1(i,:)))/cos(th1(i,:)))-((sin(th1(i,:)))*sin(th1(i,:))/cos(th1(i,:))));
th3(i,:) = atan2(((ay*sin(th1(i,:)))/cos(th1(i,:)))+(ax)+(sin(th1(i,:))),(ay)-((ax*sin(th1(i,:)))/cos(th1(i,:)))-((sin(th1(i,:)))*sin(th1(i,:))/cos(th1(i,:))));
end
count =0;
for i = 1:m+1
figure(1)
ARM1 = Tranf([th1(i,:) d1 0 pi/2]);
ARM2 = Tranf([th2(i,:) 0 a2 0]);
ARM3 = Tranf([th3(i,:) 0 a3 0]);
POSITION = eval((T03s));
p(:,i) = POSITION*[0 0 0 1]';
% LOCATING THE INDIVIDUAL JOINTS %

JOINT1(:,i) = ARM1*[0 0 0 1]';
JOINT2(:,i) = ARM1*ARM2*[0 0 0 1]';
JOINT3(:,i) = ARM1*ARM2*ARM3*[0 0 0 1]';
% PLOTTING LINES THAT REPRESENT THE LINKS %

ORIGIN = zeros(4,50);
plot3(p(1,i),p(2,i),p(3,i)),hold on
view(0,90)
plot3(subs(JOINT3(1,i)),subs(JOINT5(2,i)),subs(JOINT3(3,i)),'k*','MarkerSize',10)
plot3([0;0],[0;0],[0;300],'k','LineWidth',10)
plot3([subs(JOINT1(1,i));subs(JOINT2(1,i))],[subs(JOINT1(2,i));subs(JOINT2(2,i))],[subs(JOINT1(3,i));subs(JOINT2(3,i))],'r','LineWidth',10)
plot3([subs(JOINT2(1,i));subs(JOINT3(1,i))],[subs(JOINT2(2,i));subs(JOINT3(2,i))],[subs(JOINT2(3,i));subs(JOINT3(3,i))],'g','LineWidth',10)
%legend('Tool Point','Base','Arm 1','Arm 2','Arm 3','Tool')

% PLOTTING JOINT LOCATIONS WITH BLACK DOTS %

plot3(0,0,0,'k.','MarkerSize',10)
plot3(subs(JOINT1(1,i)),subs(JOINT1(2,i)),subs(JOINT1(3,i)),'k.','MarkerSize',10)
plot3(subs(JOINT2(1,i)),subs(JOINT2(2,i)),subs(JOINT2(3,i)),'k.','MarkerSize',10)
plot3(subs(JOINT3(1,i)),subs(JOINT3(2,i)),subs(JOINT3(3,i)),'k.','MarkerSize',10)
grid
axis([-50,500,-200,200,0,750])
hold off
pause(.01)
count = count+1;
end
hold on
x1 = JOINT3(1,:);
y1 = JOINT3(2,:);
z1 = JOINT3(3,:);
plot3(x1,y1,z1)
for i = 1:m+1
figure(2)
ARM1 = Tranf([th1(i,:) d1 0 pi/2]);
ARM2 = Tranf([th2(i,:) 0 a2 0]);
ARM3 = Tranf([th3(i,:) 0 a3 0]);
POSITION = eval((T03));
p(:,i) = POSITION*[0 0 0 1]';
% LOCATING THE INDIVIDUAL JOINTS %
JOINT1(:,i) = ARM1*[0 0 0 1]';
JOINT2(:,i) = ARM1*ARM2*[0 0 0 1]';
JOINT3(:,i) = ARM1*ARM2*ARM3*[0 0 0 1]';
% PLOTTING LINES THAT REPRESENT THE LINKS %
ORIGIN = zeros(4,50);
plot3(p(1,i),p(2,i),p(3,i)),hold on
view(0,0)
plot3(subs(JOINT3(1,i)),subs(JOINT3(2,i)),subs(JOINT3(3,i)),'k*','MarkerSize',10)
plot3([0;0],[0;0],[0;300],'k','LineWidth',10)
plot3([subs(JOINT1(1,i));subs(JOINT2(1,i))],[subs(JOINT1(2,i));subs(JOINT2(2,i))],[subs(JOINT1(3,i));subs(JOINT2(3,i))],'r','LineWidth',10)
plot3([subs(JOINT2(1,i));subs(JOINT3(1,i))],[subs(JOINT2(2,i));subs(JOINT3(2,i))],[subs(JOINT2(3,i));subs(JOINT3(3,i))],'g','LineWidth',10)
%legend('Tool Point','Base','Arm 1','Arm 2','Arm 3','Tool')
% PLOTTING JOINT LOCATIONS WITH BLACK DOTS %
plot3(0,0,0,'k.','MarkerSize',10)
plot3(subs(JOINT1(1,i)),subs(JOINT1(2,i)),subs(JOINT1(3,i)),'k.','MarkerSize',10)
plot3(subs(JOINT2(1,i)),subs(JOINT2(2,i)),subs(JOINT2(3,i)),'k.','MarkerSize',10)
plot3(subs(JOINT3(1,i)),subs(JOINT3(2,i)),subs(JOINT3(3,i)),'k.','MarkerSize',10)
grid
axis([-50,500,-200,200,0,750])
hold off
pause(.01)
count = count+1;
end

Best Answer

Tranf is not a Mathworks supplied function, and is not in any contribution on the File Exchange either. I am not able to identify any third-party software that defines it either. We do not know what it is intended to do.
You did not include the complete error message, so we do not know which line the problem is occurring on.