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 visualización (últimos 30 días)
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)

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Mayo de 2021
In your for i loop you overwrite all of y every iteration. You should be writing to y(i)

Categorías

Más información sobre Electrical Block Libraries en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by