Borrar filtros
Borrar filtros

I have this error Index in position 1 exceeds array bounds

16 visualizaciones (últimos 30 días)
Ho Kok Hoe
Ho Kok Hoe el 16 de Ag. de 2023
Respondida: Riya el 7 de Sept. de 2023
The code as below but I could not find where is the problem is. Appreciate your advise.
function [DH_Table, T_Base, Parameters] = DH_Bioloid
%DH_BIOLOID DH table for the Dynamixel Bioloid robot
%Output
% DH_Table [1x1] struct of DH tables for each limb
% T_Base [1x1] struct of T-matrices representing the location of
% each limb base relative to body {B}
% Parameters DH parameter a and d values (in metres)
d = [ 72 22 42.5 38.75 120.75 ]*1e-3;
a = [ 11.5 68 106 76.98 76.94 33 ]*1e-3;
%% Limb Upper Left
T_Base.Limb_Upper_Left = [
% ============= YOUR CODE (START) ================
% Fill matrix here, for example
% 1 0 0 0;
% 0 1 0 0;
% 0 0 1 0;
% 0 0 0 1
% ============== YOUR CODE (END) =================
];
th1 = sym('theta_1', [1 3], 'real');
DH_Table.Limb_Upper_Left = [
% ============= YOUR CODE (START) ================
% Fill matrix here, for example
% 0 0 0 th(1);
% pi/2 a(2) d(2) th(2);
% 0 0 0 th(3)+pi/2;
% 0 0 0 pi
% ============== YOUR CODE (END) =================
];
%% Limb Upper Right
T_Base.Limb_Upper_Right = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
th2 = sym('theta_2', [1 3], 'real');
DH_Table.Limb_Upper_Right = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
%% Limb Lower Left
T_Base.Limb_Lower_Left = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
th3 = sym('theta_3', [1 6], 'real');
DH_Table.Limb_Lower_Left = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
%% Limb Lower Right
T_Base.Limb_Lower_Right = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
th4 = sym('theta_4', [1 6], 'real');
DH_Table.Limb_Lower_Right = [
% ============= YOUR CODE (START) ================
% ============== YOUR CODE (END) =================
];
%% Finalise outputs
Parameters = struct('th',[th1 th2 th3 th4],'d',d,'a',a);
%% Uncomment to use given solution for debug purposes
% [DH_Table, T_Base, Parameters] = DH_Bioloid_soln;
end
  2 comentarios
John D'Errico
John D'Errico el 16 de Ag. de 2023
You could not find where the prolem is? You did not write any code.
DGM
DGM el 16 de Ag. de 2023
Editada: DGM el 16 de Ag. de 2023
This is clearly an empty function template that hasn't been filled in. It's fairly obvious that it won't work unless you complete the code. It's also a function, so it's not at all clear how you're trying to call it. I say that since calling it as-is won't actually result in any error. Whatever you're doing to produce the error is external to this code and unknown to us, even if it's caused by the fact that this code is incomplete.

Iniciar sesión para comentar.

Respuestas (1)

Riya
Riya el 7 de Sept. de 2023
Hello Ho Kok Hoe,
As per my understanding, you have encountered an error: Index in position 1 exceeds array bounds.
Please note that, the error Index in position 1 exceeds array bounds typically occurs when you try to access an element in an array using an index that is out of range. In your code, the error is likely due to accessing an element in an array using an incorrect index.
To identify the specific line causing the error, you can enable debugging by adding a breakpoint or using the MATLAB debugger. However, based on the provided code. The error is likely occurring because you are attempting to access elements in arrays `th1`, `th2`, `th3`, and `th4` using indices that are out of range. In the code snippet you provided, you have defined `th1` as a 1x3 symbolic variable, `th2` as a 1x3 symbolic variable, `th3` as a 1x6 symbolic variable, and `th4` as a 1x6 symbolic variable. However, you are trying to access elements beyond the defined range.
To fix this issue, you need to ensure that the indices you use to access elements in these arrays are within the defined ranges. For example, if you want to access the first element of `th1`, you can use `th1(1)` instead of `th1(2)`. Similarly, make sure that the indices used for `th2`, `th3`, and `th4` are within their respective ranges.
Please review your code and adjust the indices accordingly to resolve the "Index in position 1 exceeds array bounds" error.
In case you further require a more specific solution tailored to your case, you can provide more information about the function definition rather than the empty function.
I hope it helps!

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by