Index exceeds array dimensions. Index value 150002 exceeds valid range [1-150001] for array 'v'.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Moath el dalahmeh
le 14 Avr 2022
Réponse apportée : VBBV
le 14 Avr 2022
I tried to run this sentence using Simulink but this error keeps popping upfor
for n = 1:length(t); % Start simulation
v(n+1) = v(n) + (g*sin(theta(n)) - k./m.*v(n)).*dt;
theta(n+1) = theta(n) - 1./L.*v(n).*dt;
end
0 commentaires
Réponse acceptée
VBBV
le 14 Avr 2022
for n = 1:length(t)-1;
Error shows clearly that vector v has 1 additional element. Change the loop as above since v(n+1) should correspond to last element in vector v. A better way is to preaalocate array as
v = zeros(1,length(t))
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!