Left and Right side have different elements
1 回表示 (過去 30 日間)
古いコメントを表示
For theta_dot(i) specifically, I keep running into the error "Unable to perform assignment because the left and right sides have a different number of elements". I'm amateur with MatLab and need help fixing that line.
t = 0:0.01:4; % Timesteps for robotic arm motion
for i = 1:length(t)
% Position of robotic arm in r-theta coordinates
theta(i) = -(pi/4)*t.^2+pi*t;
r(i) = 3+0.5*cos(4*theta(i));
% Position of robotic arm in x-y coordinates
x(i) = r(i)*cos(theta(i));
y(i) = r(i)*sin(theta(i));
% Velocity of robotic arm in radial/transverse components
theta_dot(i) = -(pi/2)*t+pi;
r_dot(i) = pi*sin(4*theta(i));
v_r(i) = r_dot(i);
v_theta(i) = (r(i)*theta_dot(i));
% Velocity of robotic arm in Cartesian coordinates
% v_x(i) = MODIFY;
% v_y(i) = MODIFY;
0 件のコメント
回答 (2 件)
Star Strider
2024 年 4 月 17 日
You need to subscript ‘t’.
Then, it works —
t = 0:0.01:4; % Timesteps for robotic arm motion
for i = 1:length(t)
% Position of robotic arm in r-theta coordinates
theta(i) = -(pi/4)*t(i).^2+pi*t(i); % <— Changed: 't' To 't(i)'
r(i) = 3+0.5*cos(4*theta(i));
% Position of robotic arm in x-y coordinates
x(i) = r(i)*cos(theta(i));
y(i) = r(i)*sin(theta(i));
% Velocity of robotic arm in radial/transverse components
theta_dot(i) = -(pi/2)*t(i)+pi; % <— Changed: 't' To 't(i)'
r_dot(i) = pi*sin(4*theta(i));
v_r(i) = r_dot(i);
v_theta(i) = (r(i)*theta_dot(i));
% Velocity of robotic arm in Cartesian coordinates
% v_x(i) = MODIFY;
% v_y(i) = MODIFY;
end
v_theta
figure
plot(t, v_theta)
grid
xlabel('t')
ylabel('v\_theta')
.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Robotics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!