Effacer les filtres
Effacer les filtres

this code is related o signal processing .

3 vues (au cours des 30 derniers jours)
Raj Arora
Raj Arora le 14 Déc 2021
i am getting a error regarding [] missing. although I believe all the brackets have been labelled properly.Any help of would be really helpful
  2 commentaires
Raj Arora
Raj Arora le 14 Déc 2021
clc;clear all;close all;
p=2;M=p+1;N=31;
n=0:N+M-2;
Nfft=1024;
wn=randn(1,N+M-1);
xn=exp(1i*2*pi*0.2*n)+5*exp(1i*2*pi*0.3*n)+wn;
%X=[xn(1:31).'xn(2:32).' xn(3:33).' ;(4:34).' ;(M:N+M-1).']
R=(1/N)*[X'*X];
[Q0,D]=eig(R);
[lambda,index]=sort(abs(diag(D)));
Lambda=lambda(M:-1:1);
Q=Q0(:,index(M:-1:1));
Qbar=zeros(Nfft,1);
for i=1:M-p
Qbar=Qbar+abs(fftshift(fft(Q(:,M-(i-1)),Nfft)));
end
Rbar=1./Qbar;
w=-0.5:0.000977:0.5;
RbardB=10*log10(Rbar);
Plot(w,RbardB);
grid on;
xlabel("frequency in pi units")
ylabel("MUSIC Spectrum (dB)");
Raj Arora
Raj Arora le 14 Déc 2021
erroe occurs on the commented line

Connectez-vous pour commenter.

Réponse acceptée

Chunru
Chunru le 14 Déc 2021
Modifié(e) : Chunru le 14 Déc 2021
clc;clear all;close all;
p=2; M=p+1; N=31;
n=0:N+M-2;
Nfft=1024;
wn=randn(1,N+M-1);
xn=exp(1i*2*pi*0.2*n)+5*exp(1i*2*pi*0.3*n)+wn;
%X=[xn(1:31).'xn(2:32).' xn(3:33).';(4:34).' ;(M:N+M-1).']
whos
Name Size Bytes Class Attributes M 1x1 8 double N 1x1 8 double Nfft 1x1 8 double n 1x33 264 double p 1x1 8 double wn 1x33 264 double xn 1x33 528 double complex
X=[xn(1:31).' xn(2:32).' xn(3:33).' ]; % is this what you want?
R=(1/N)*[X'*X];
[Q0,D]=eig(R);
[lambda,index]=sort(abs(diag(D)));
%whos
Lambda=lambda(M:-1:1);
Q=Q0(:,index(M:-1:1));
Qbar=zeros(Nfft,1);
for i=1:M-p
Qbar=Qbar+abs(fftshift(fft(Q(:,M-(i-1)),Nfft)));
end
Rbar=1./Qbar;
w=-0.5:0.000977:0.5;
RbardB=10*log10(Rbar);
plot(w,RbardB);
grid on;
xlabel("frequency in pi units")
ylabel("MUSIC Spectrum (dB)");
  4 commentaires
Raj Arora
Raj Arora le 14 Déc 2021
getting similar error here as well..
Chunru
Chunru le 14 Déc 2021
clc;clear all;close all;
p=2;M=p+1;N=31;
n=0:N+M-2;
wn=0.05*randn(1,N+M-1);
xn=sin(2*pi*0.2*n)+wn;
X=[xn(1:31)' xn(2:32)' xn(3:33)'];
% ^ ^ spaces are needed
R=(1/N)*[X'*X];
[Q0,D]=eig(R);
[lambda,index]=sort(abs(diag(D)));
lambda=lambda(M:-1:1);
Q=Q0(:,index(M:-1:1));
Rbar=1./abs(fftshift(fft(Q(:,M),1024)));
w=-0.5:0.000977:0.5;
RbardB=10*log10(Rbar);
plot(w,RbardB);
grid on;

Connectez-vous pour commenter.

Plus de réponses (1)

Raj Arora
Raj Arora le 14 Déc 2021
thanks

Community Treasure Hunt

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

Start Hunting!

Translated by