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.

 Accepted Answer

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

2 Comments

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

Sign in to comment.

More Answers (0)

Products

Asked:

on 8 May 2020

Commented:

on 8 May 2020

Community Treasure Hunt

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

Start Hunting!