this code is related o signal processing .

3 次查看(过去 30 天)
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)");

请先登录,再进行评论。

采纳的回答

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 个评论
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