Array indices must be positive integers or logical values for loop expression

1 vue (au cours des 30 derniers jours)
SL
SL le 27 Août 2021
Commenté : SL le 30 Août 2021
i do not know why but when I run this I get the error that array indicies must be positive, it is , isnt it ? Please help thanks
Nu = 300; % nu of samples
N = 700; % number of learning samp0les
D = 5; % some constant
cdot(1) = [100];
Co(1) = 10;
% initialize
%first derivate
x = [1.2 1.23 1.55 1.6 1.66 1.85 1.9 1.92 1.95 1.9544.....
1.9611 1.9626 1.9788 1.98 1.9822 1.9855 1.9899 1.925];
t = 1:60;
for i =0:100
cdot(i+1) = cdot(i) - Co(i) + (0.25*x./sqrt(D.*t(i)) + 0.5 ./ sqrt(D.*t(i)) ) .* exp(0.5.*x./sqrt(D.*t(i)));
end

Réponse acceptée

TADA
TADA le 27 Août 2021
in Matlab array indices start from 1, not 0 like other languages.
You have more bugs in this script, but this error is due to starting your loop index from zero instead of 1

Plus de réponses (1)

Image Analyst
Image Analyst le 27 Août 2021

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by