Index exceeds the number of array elements (1). Error in sym/subsref (line 909) R_tilde = builtin('s​ubsref',L_​tilde,Idx)​; Error in newuntitled2 (line 17) r(k)=r(k)+​(y(i)*conj​(y(i+k-1))​); How to solve this error?

1 回表示 (過去 30 日間)
clc;
clear all;
close all;
n=16;
pi=sym(pi)
for i=1:n
x = (pi/n)*(i-1)*(i-n-1)
y=x-2*pi*fix(x/(2*pi))
if(y<0)
y=y+(2*pi)
end
end
disp(y)
r=zeros(1,n);
for k=1:n
for i=1:n-k+1
r(k)=r(k)+(y(i)*conj(y(i+k-1)));
end
end
disp(r);
b=sort(r,'descend');
max=r(2);
s=max/r(1);
p=20*log10(s)
f=(rssq(r))^2-r(1)^2
h=(2*f)/r(1)
l= 10*log10(h)

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 5 月 28 日
In your for i loop you overwrite all of y every iteration. You should be writing to y(i)

カテゴリ

Help Center および File ExchangeElectrical Block Libraries についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by