Array indices must be positive integers or logical values
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Fs=1000
Fc=250
dF=50
Br=.001
A=-20*log(Br)
dw=2*pi*(dF/Fs)
N=floor((A-8)/(2.285*dw)+1)
b=.1102*(A-8.7)
a=(N-1)/2
prompt = 'What is the original value? ';
n = input(prompt)
w = I(b(1-((n-a)/a)^2)^.5)/I(b)
if
n==(N-1)/2
hD=2*Fc
end
else if
n~=(N-1)/2
hD=2*Fc*sin((n-((N-1)/2))*2*pi*Fc)/(n-((N-1)/2))*2*pi*Fc
plot(hD*w,n);
This code is showing "Array indices must be positive integers or logical values". why is it showing this message?
2 Comments
Walter Roberson
on 9 May 2019
w = I(b(1-((n-a)/a)^2)^.5)/I(b)
Is l a function being invoked or is it an array being indexed?
Aurick Das
on 9 May 2019
Answers (1)
Star Strider
on 9 May 2019
This line throws the error:
w = I(b(1-((n-a)/a)^2)^.5)/I(b)
To begin with, ‘I’ is not defined in your code.
That aside, ‘b’ is a scalar, and MATLAB is going to consider ‘(1-((n-a)/a)^2)’ as a subscript reference into it. That may not be an integer, and may not be positive.
You appear be missing several arithmetic operators, most likely multiplication operators. You have to define those and correct your code to elimiinate the problems with it.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!