error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
where is the error in this code??? and how to get a plot for this signal?
% _ _ signal generation
A1=10; %Amplitude 1
A2=10; %Amplitude 2
w1=2*pi*0.2; % angular frequency 1
w2=2*pi*0.225; % angular frequency 2
Ts=1; % sampling time
N=64; % no. of process samples to be generated
K=1; % no. of independent process realization
sgm=1; % standard deviation of the noise
n=repmat((0:N-1).',1,K);
phi1=repmat(rand(1,K)*2*pi,N,1); % random phase matrix 1
phi2=repmat(rand(1,K)*2*pi,N,1); % random phase matrix 2
x=A1*sin(w1*n*Ts+phi1)+A2*sin(w2*n*Ts+phi2)+sgm*randn(N,K); % resulting signal
% _ _ periodogram overlay
NFET=256; %FFT length
X=1/N*abs(fft(x,NFET)).^2; % PSD estimate using FFT
% _ _ periodogram average - -
Xav= sum (X,2)/K ; % average columns
4 Kommentare
the cyclist
am 2 Jan. 2012
enas, you seem to be posting the smallest possible amount of explanation, and hoping that we will figure out what you mean. Please provide more explanation about what you think is incorrect here. This code creates no error message for me (in version R2011b on a Mac). If you are getting an error message, please tell us what it is.
The line you mention, n= repmat((0:N-1).',1,k), creates a column vector from 0...63, as I would expect from your code, since K=1. Is that not what you want? Provide some details!
Your code does not create a figure because there are no figure-creating commands in it. Did you want to plot something? Maybe try "help plot" to get started?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!