Help me in debugging this code. Error : Unable to perform assignment because the left and right sides have a different number of elements.
古いコメントを表示
clc;
clear all;
close all;
global th
% Define joint angles
th = struct( ...
'th1', [0; 0; 0], ...
'th2', [0; pi/4; 0], ...
'th3', [0; pi/4; 0] ...
);
i = 1;
while (1)
human(th);
pause(0.1);
i = i + 1;
move1();
cla;
end
%% Motion function
function move1()
global th i
k = [1:1:10 9:-1:2];
N1 = length(k);
if i > N1
i = i - N1;
elseif i < 1
i = i + N1;
end
% Interpolation index
index1 = (k(i) - 1) / 9;
% ERROR MAY OCCUR HERE
th.th2(2) = pi/4 + (pi/2) * index1;
th.th3(2) = pi/4 - (pi/2) * index1;
end
%% Human visualization function
function human(th)
% Accessing angles
th1_1 = th.th1(1);
th2_2 = th.th2(2);
% ERROR MAY OCCUR IF STRUCTURE INDEXING IS WRONG
disp(['th1_1: ', num2str(th1_1)]);
disp(['th2_2: ', num2str(th2_2)]);
end
So i am trying to make a humanoid moving. So for that i am modifying the theta(th) and i am getting this error but both the LHS and RHS is scalar. Still it is showing this error. Any ideas will help....
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!