Molly McDonough
Molly McDonough

Reputation: 107

Why am I getting "Array indices must be positive integers or logical values."

Can anyone find where my code is throwing an error for this function? alpha_p and width are both arrays where all numbers are positive.

gain2 = (alpha_p.'./(1-exp(-alpha_p.'.*width.'))).*((((2.*(exp((-2.*alpha_.*(1-k)-alpha_p.').*width.'))-1))./(-2.*alpha_.*(1-k)-alpha_p.'))-(((exp(-2.*alpha_.*(1-k).*width')-k)./(exp(-alpha_(1-k).*width.')-k)).*((1-exp((-alpha_.*(1-k)-alpha_p.').*width.'))./(alpha_.*(1-k)+alpha_p.'))));

Upvotes: 0

Views: 1058

Answers (1)

MichaelTr7
MichaelTr7

Reputation: 4767

The error propagates from the section indicated by the box in the below image. May be caused by a missing operator between -alpha_ and (1-k). Assuming of course that the variable alpha_ is a constant/scalar and not another array.

Error Image

Extension: Debugged using find functionality on each variable and looking for any variable that does not follow valid indexing.

Upvotes: 1

Related Questions