对 MATLAB 创建的函数进行故障排除



美好的一天!

我对 MATLAB 相当陌生,似乎在制作简单函数时遇到了一些问题。假设该函数输出一个串联的 4*4 矩阵。我的代码如下:

function T_G = JointMatrix(alpha,a,theta,d)
% The general transformation matrix for joint n from joint n-1.
% Prompt: Input row parameter values to recieve matrix.
T_G = zeros(4,4);
R = [cosd(theta) -sind(theta) 0;
    sind(theta)*cosd(alpha) cosd(theta)*cosd(alpha) -sind(alpha);
    sind(theta)*sind(alpha) cosd(theta)*sind(alpha) cosd(alpha);0 0 0];
P = [a;-sind(alpha)*d;cosd(alpha)*d;1];
T_G = [R P]
end

你的代码很好。

JointMatrix(0,1,0,1)
T_G =
     1     0     0     1
     0     1     0     0
     0     0     1     1
     0     0     0     1

确保您位于正确的目录中。

最新更新