Left and Right side have different elements
조회 수: 2 (최근 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!