Clear Filters
Clear Filters

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 view (last 30 days)
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--')

Answers (1)

madhan ravi
madhan ravi on 30 Jan 2019
Edited: madhan ravi on 30 Jan 2019
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--')

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!