matlab error -> index must be a positive integer or logical.

Hi!! I am matlab beginner...
I don't know how to solve the problem.
I think it is integer problem....
function [x, y, z] = FDH(Dtheta1,Dtheta2,Dtheta3,Dtheta4,Dtheta5,Dtheta6)
theta1 =Dtheta1;
theta2 =Dtheta2;
theta3 =Dtheta3;
theta4 =Dtheta4;
theta5 =Dtheta5;
theta6 =Dtheta6;
l3 = 6.5;
l4 = 6.5;
l6 = 6.5;
H01 = [-sind(theta1) 0 cosd(theta1) 0;cosd(theta1) 0 sind(theta1) 0;0 1 0 0;0 0 0 1];
H12 = [sind(theta2) 0 sind(theta2) 0;-cosd(theta2) 0 sind(theta2) 0;0 -1 0 0;0 0 0 1];
H23 = [cosd(theta3) -sind(theta3) 0 l3*cosd(theta3);sind(theta3) cosd(theta3) 0 l3*sind(theta3);0 0 1 0;0 0 0 1];
H34 = [cosd(theta4) -sind(theta4) 0 l4*cosd(theta4);sind(theta4) cosd(theta4) 0 l4*sind(theta4);0 0 1 0;0 0 0 1];
H45 = [cosd(theta5) 0 sind(theta5) 0;sind(theta5) 0 -cosd(theta5) 0;0 1 0 0;0 0 0 1];
H56 = [cosd(theta6) -sind(theta6) 0 l6*cosd(theta6);sind(theta6) cosd(theta6) 0 l6*sind(theta6);0 0 1 0;0 0 0 1];
H6F = [0 0 -1 0;0 1 0 0;1 0 0 0;0 0 0 1];
H0F = H01 * H12 * H23 * H34 * H45 * H56 * H6F
x =H0F(0,3);
y =H0F(1,3);
z =H0F(3,3);
x,y,z -> Attempted to access H0F(0,3); index must be a positive integer or logical.

 Réponse acceptée

0 is not a valid index in MATLAB. MATLAB indices start at 1. You probably want
x = H0F(1,3);
y = H0F(2,3);
z = H0F(3,3);

Plus de réponses (1)

Catégories

En savoir plus sur Mathematics and Optimization dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by