Index exceeds number of array elements. How can I fix this?
1 回表示 (過去 30 日間)
古いコメントを表示
clear
clc
close all
%%Length of links in m
L2=1.4
L3=4
L4=-1
%%Open vs Crossed
OC='O'
%%Length of P in m
rp=3
%%delta angle in degrees
d_a=15
%%Convert delta to radians
da=d_a*(pi/180)
%%Omega2 in rad/s
OM2=10
%%Theta2
for i=1:361
theta2=(i-1)*pi/180
theta_2(i)=theta2
end
%%Calculation of theta3
if OC==['O']
theta_3=180-asind((L2*sin(theta2)-L4)/(L3))
else
theta_3=asind((L2*sin(theta2)-L4)/(L3))
end
%%Convert theta 3 to radians
theta3=theta_3*(pi/180)
%%Theta 4 to radians
theta4(i)=90*(pi/180)
%%Calculation of position L1
L1(i)=L2*cos(theta2)-L3*cos(theta3(i))
%%Omega 3
OM3(i)=OM2*((L2*cos(theta2))/(L3*cos(theta3(i))))
%%Linear velocity of slider
L1dot=-L2*OM2*sin(theta2)+L3*OM3(i)*sin(theta3(i))
Index
exceeds
the
number
of
array
elements.
Index
must
not
exceed
1.
Error in Hw10_1 (line 46)
L1(i)=L2*cos(theta2)-L3*cos(theta3(i))
0 件のコメント
採用された回答
KSSV
2021 年 11 月 5 日
Replace this line:
L1(i)=L2*cos(theta2)-L3*cos(theta3(i))
with
L1=L2*cos(theta2)-L3*cos(theta3)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!