Array indices must be positive integers or logical values.

Why do I get this error?
>> x=linspace(0,10,1000)';
>> y1(x)=cos(x).^2.*exp(-0.4.*x)
Array indices must be positive integers or logical values.

 采纳的回答

x = linspace(0,10,1000)';
y1 =cos(x).^2.*exp(-0.4.*x) ;
It is array operation...you don't need to index.

2 个评论

In MATLAB indices should be positive integers. Indices cannot be zero, negative integers and fractions.
Thanks is accepting the answer.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by