Filter löschen
Filter löschen

this code is related o signal processing .

3 Ansichten (letzte 30 Tage)
Raj Arora
Raj Arora am 14 Dez. 2021
Beantwortet: Raj Arora am 14 Dez. 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 Kommentare
Raj Arora
Raj Arora am 14 Dez. 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 am 14 Dez. 2021
erroe occurs on the commented line

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 14 Dez. 2021
Bearbeitet: Chunru am 14 Dez. 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 Kommentare
Raj Arora
Raj Arora am 14 Dez. 2021
getting similar error here as well..
Chunru
Chunru am 14 Dez. 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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Raj Arora
Raj Arora am 14 Dez. 2021
thanks

Community Treasure Hunt

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

Start Hunting!

Translated by