Array indices must be positive integers or logical values
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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 个评论
Walter Roberson
2019-5-9
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
2019-5-9
回答(1 个)
Star Strider
2019-5-9
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.
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!