Array indices must be positive integers or logical values.
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
VBBV
2020-12-10
%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
0 个评论
更多回答(1 个)
Théophane Dimier
2020-12-10
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!