Array indices must be positive integers or logical values.

3 vues (au cours des 30 derniers jours)
Idris Phillips-Fry
Idris Phillips-Fry le 10 Déc 2020
Réponse apportée : VBBV le 10 Déc 2020
keep getting title error message with this code in MATLAB.
a=exp(-1);
o=0.009931621960609;
x2=-2.5:0.1:9.5;
y2=0.5*exp(-a(x2-(0.5*o^2*a)))*(1+erf((x2-o^2*a)/sqrt(2)*o));
o is standard dev of data, a is placeholder value for decay constant.

Réponse acceptée

VBBV
VBBV le 10 Déc 2020
%true
a=exp(-1);
o=0.009931621960609;
x2=-2.5:0.1:9.5;
y2=0.5*exp(-a*(x2-(0.5*o^2*a))).*(1+erf((x2-o^2*a)/sqrt(2)*o));
Use element wise matrix multiplication and operation as above

Plus de réponses (1)

Théophane Dimier
Théophane Dimier le 10 Déc 2020
you may have forgot a multipkliication sign:
y2=0.5*exp(-a*(x2-(0.5*o^2*a)))*(1+erf((x2-o^2*a)/sqrt(2)*o));
|
here
Matlab was then understanding that you wanted to access a element of a as if it was an array.

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by