Index exceeds the number of array elements (1). Error in HW08_Spaceship (line 34) xT =(5*(cos(4​5)+B(T+Kon​e)*sin(T)/​2+sin(45)+​B*(T+1/Kon​e)*cos(T))​) >>

1 次查看(过去 30 天)
R= 40;
Xo= 125;
B = 42;
Kone = 5;
T = 0: 30;
xT =(5*(cos(45)+B(T+Kone)*sin(T)/2+sin(45)+B*(T+1/Kone)*cos(T)))
yT =(5*(sin(45)+B(T+Kone)*sin(T)/2-cos(45)+B*(T+1/Kone)*cos(T)))
plot (xT,yT,'r--')

回答(1 个)

madhan ravi
madhan ravi 2019-1-30
编辑:madhan ravi 2019-1-30
Suspect it should be sind() and cosd() ?:
R= 40;
Xo= 125;
B = 42;
Kone = 5;
T = 0:30;
% v-----------------------------v-----missed it
xT =(5*(cos(45)+B*(T+Kone).*sin(T)/2+sin(45)+B*(T+1/Kone).*cos(T)))
% ^---- was the reason for your error
% v-----------------------------v-----missed it
yT =(5*(sin(45)+B*(T+Kone).*sin(T)/2-cos(45)+B*(T+1/Kone).*cos(T)))
% ^---- was the reason for your error
plot (xT,yT,'r--')

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by