필터 지우기
필터 지우기

this code is related o signal processing .

조회 수: 3 (최근 30일)
Raj Arora
Raj Arora 2021년 12월 14일
답변: Raj Arora 2021년 12월 14일
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
Raj Arora
Raj Arora 2021년 12월 14일
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 2021년 12월 14일
erroe occurs on the commented line

댓글을 달려면 로그인하십시오.

채택된 답변

Chunru
Chunru 2021년 12월 14일
편집: Chunru 2021년 12월 14일
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
Raj Arora
Raj Arora 2021년 12월 14일
getting similar error here as well..
Chunru
Chunru 2021년 12월 14일
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;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Raj Arora
Raj Arora 2021년 12월 14일
thanks

카테고리

Help CenterFile Exchange에서 Signal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by