用matlab语言产生一个正弦信号,进行频谱分析和自相关分析,求教~~~~~谢谢啊 关于用MATLAB对信号进行频谱分析程序

作者&投稿:陆竿 (若有异议请与网页底部的电邮联系)

下面matlab程序,按照你的要求编写的。

fs=100;N=200;

lag=100;

%randn('state',0);   %设置产生随机数的初始状态(噪声)

n=0:N-1;t=n/fs;

x1=sin(2*pi*10*t)+2*sin(2*pi*15*t)  

y=fft(x1,N);                                  %计算频谱

mag=abs(y);

f=n*fs/N;

figure(1)

subplot(2,2,1),plot(t,x1);

title('原始信号'),xlabel('时间/s');

subplot(2,2,2),plot(f(1:N/2),mag(1:N/2)*2/N);

title('频谱图'),xlabel('频率/Hz');

[c,lags]=xcorr(x1,lag,'unbiased');             % 自相关

subplot(2,2,3),plot(lags/fs,c);

title('自相关信号'),xlabel('时间/s');

m=length(c)-1;                            

z=fft(c,m);                                  

mag_z=abs(z);

ff=(0:m-1)*fs/m;

subplot(2,2,4),plot(ff(1:m/2),mag_z(1:m/2)*2/m);

title('自相关频谱'),xlabel('频率/Hz');

figure(2)

[c1,lags1]=xcorr(x1,randn(1,length(t)),lag,'unbiased'); 

m1=length(c1)-1;                            

z1=fft(c1,m1);                                  

mag_z1=abs(z1);

ff1=(0:m1-1)*fs/m1;

subplot(2,1,1),plot(lags1/fs,c1);

title('互相关信号'),xlabel('时间/s');

subplot(2,1,2),plot(ff1(1:m1/2),mag_z1(1:m1/2)*2/m1);

title('互相关频谱'),xlabel('频率/Hz');




% The number of data points for y should be power of 2, and
% truncation is needed to achieve the requirement
%--------------------------------------------------------------------------
% (1) Compute number of data points and sampling time interval
%--------------------------------------------------------------------------
ntime=max(size(t));
dt=(t(1,ntime)-t(1,1))/(ntime-1);
%--------------------------------------------------------------------------
% (2) Truncate the data points of y
%--------------------------------------------------------------------------
% Extract data points at the power of 2. Truncate extra data points
% so that the final number of data points is in the power of two and
% also as close as possible to the given number of data points
N=fix(log10(ntime)/log10(2))
%--------------------------------------------------------------------------
% (3) Calculate FFT
%--------------------------------------------------------------------------
% Calculate FFT of the time domain data and
% take absolute values of the result
yfft=fft(y(1:2^N,:));
yfft=abs(yfft(1:2^N/2,:))*dt;
%--------------------------------------------------------------------------
% (4) Calculate frequency vector
%--------------------------------------------------------------------------
% Set up the frequency scale from the given sampling interval.
% Apply the Nyquist criterion to establish the maximum frequency
freq0=0;
freqf= (1/dt)/2; % Maximum or final frequency value
df=freqf/(2^N/2); % Frequency interval

freq=0:df:freqf-df; % Frequency axis values

怎么用matlab语言对一个由几个正弦信号组成的信号进行频谱分析~

用fft()函数即可。
因为你没提具体的应用要求,所以我把matlab关于fft的例子贴给你,以供参考。
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')

ss=a1.^s+a3.^s.^s.^s;

这句是非线性放大器a*x+b*x*x*x么?
不是应该是a1.*s+a2.*x.*x.*x么?

...的正弦信号,对其进行Hilbert 变换,并产生其频谱图。用Matlab...
答:N = 1024; %样本数fs = 1000; %采样率t = (0:N-1)/fs;xn = sin(2*pi*100.*t); %100Hz正弦信号采样hxn = hilbert(xn); %做希尔伯特变换%比较频谱X = fft(xn);H = fft(hxn);subplot(221);plot(abs(X));title('原信号频谱幅值');subplot(222);plot(phase(X));...

用matlab语言产生一个正弦信号,进行频谱分析和自相关分析,求教~~~谢谢...
答:lag=100;randn('state',0); %设置产生随机数的初始状态(噪声)n=0:N-1;t=n/fs;x1=sin(2*pi*10*t)+2*sin(2*pi*15*t)y=fft(x1,N); %计算频谱 mag=abs(y);f=n*fs/N;figure(1)subplot(2,2,1),plot(t,x1);title('原始信号'),xlabel('时间/s');subplot(2,2,2)...

如何用matlab生成正弦信号?怎么对其采样?怎么得到采样值?
答:输入一下信号可以实现生成正弦信号,并对其采样和得到采样值。f=100;%信号频率Hzfs=1000;%采样频率HzN=20;%采样点数t=(0:N-1)/fs;%采样时间sx=sin(2*pi*f*t);%信号采样值plot(t,x,'.')MATLAB简介:MATLAB 是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计...

matlab 生成一个频率为10hz,相位0的正弦信号,采样率为1000,信号长度为...
答:y=sin(2*pi*10*x);figure(1)plot(x,y)w=rand(1,1001);yw=y+w;figure(2)plot(x,yw)

用MATLAB产生一个正弦序列,信号频率200赫兹,信号长度1S,采样率1千赫兹...
答:应该是指信号的物理频率,该信号由3种频率成分的正弦信号组成。一种简单的信号生成方式如下: f1=100;%信号频率Hz f2=150;%信号频率Hz f3=200;%信号频率Hz fs=1000;%采样频率Hz N=20;%采样点数 t=(0:N-1)/fs;%采样时间s x1=sin(2*pi*f1*t);%信号采样值 x2=sin(2 ...

如何用matlab生成一个频率渐变的正弦信号
答:fs=2000; %采样频率,按照采样定理200hz即可,但为了光滑好看,因为信号时间较短,还是要多一些t=0:1/fs:(t1+t2);%信号时间数组 y=sin(f1*2*pi*t).*(t>=0&t<=t1)+sin(f2*2*pi*(t-t1)).*(t>=t1&t<=(t1+t2));%信号起始点都从0开始的正弦波,相位为零,最后相加。plot(t,y...

MATLAB中正弦信号怎么输入?
答:Simulink环境下有对应的SRC功能块,如果用m文件写的话 A=1.0 %正弦信号的幅值 w=2*pi; %正弦信号的频率 ph=0; %正弦信号的初始相位 fs=100; %采样频率 t=0;for m=1:1000 y=A*sin(w*t+ph);t=t+1/fs;你要进行的后续操作 end plot(t,y);...

运用MATLAB语言,对正弦信号进行均匀PCM量化编码。产生一幅度为1...
答:clear;clc;close all;M=7; %电平阶数8 = 0-7 A=1; f=1; w=0; %正弦信号参数 fs = 10*M; %采样频率,fs 》2*f t = 0:1/fs:2/f; %时间间隔 st=A*sin(2*pi*f*t+w);PCM=round(M*st/A)/M;plot(st);hold on; grid on;stairs(PCM,'r');运行以上代码,即可获得...

matlab如何产生一个有噪声的正弦信号
答:首先在0至2π内产生40个点(随你也可产生任意点数),注意噪声的点数与x的点数相同,在命令提示符下输入:>>x=linspace(0,2,40);>> y=sin(x*pi);>> z=y+0.2*rand(1,40);>> plot(z)

如何用matlab产生一个多次叠加的含高斯噪声的正弦波信号?
答:clear;clc;N=1000;Fs=1000;t=0:(1/Fs):(N-1)*(1/Fs);f=[50 100 150 200 250];s=zeros(1,N);for i=1:length(f)s=s+sin(2*pi*f(i)*t);end noise=0.1*randn(1,N);r=s+noise;plot(t,r);