Filter löschen
Filter löschen

Index exceeds number of array elements. How can I fix this?

1 Ansicht (letzte 30 Tage)
JAKE WISNIEWSKI
JAKE WISNIEWSKI am 5 Nov. 2021
Beantwortet: KSSV am 5 Nov. 2021
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))

Akzeptierte Antwort

KSSV
KSSV am 5 Nov. 2021
Replace this line:
L1(i)=L2*cos(theta2)-L3*cos(theta3(i))
with
L1=L2*cos(theta2)-L3*cos(theta3)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by