
呵呵,你的for循环族伍用错了。把t=-50:50提到for循环前。
clear all
close all
dt=5*exp(-12)
freq=10^5
t=-50:1:50
lt=length(t)
V0=1
for k=1:1:lt
v(k)=(1-2*((((4/freq)/dt+1)/2-t(k)+1)*freq*dt)^2)*exp(-((((4/freq)/dt+1)/2-t(k)+1)*freq*dt)^2)
end
plot(t,v)
title('Ricker-雷克子波')
xlabel('时间兆清或(ns)正枝')
ylabel('幅值')
还有你的dt和freq不太匹配,不过程序你可以自己改变的。有图片
雷克子波及其振幅谱的matlab输出:
fm=50%主频
dt=0.001%时间域采样间隔
number=100%采样点数
t=-number/2+1:number/2
a=(1-2*(pi*fm*t*0.001).^2).*exp(-(pi*fm*t*0.001).^2)
subplot(2,1,1)
plot(t,a)
title('Ricker-雷克子波')
xlabel('时间t(ms)')
ylabel('幅值A')
for i=1:100
f(i)=10*(i-1)%计算频率
end
Y=abs(fft(a))%fourier变换,取振幅谱
subplot(2,1,2)
plot(f,Y)
title('Ricker子波的振幅谱')
xlabel('频率f(hz)')
ylabel('振幅森亩胡谱')
%注耐旦:时间域采样间隔为0.001s,采样点数为100点,总的时间长度为0.1s,则频率域采样间隔此拦为10hz。
%% 自己写了如下程序,望采纳!clcclearclose all%Ricker子波前改
f=40dt=0.004
nw=6./f/dt
nw=2*floor(nw/2)+1
nc=floor(nw/2)
i=1:nw
alpha=(nc-i+1).*f*dt*pi
beta=alpha.^2
ricker=(1.-beta.*2).*exp(-beta)
subplot(311)
plot(ricker)
title('Ricker子波')
t=1:size(ricker,2)%绘制x(t)的振幅谱和相位谱
k=-25:25
W=(pi/12.5)*k
Fv=ricker*(exp(-j*pi/12.5)).^(t'*k)
magFv=abs(Fv)%绘制振幅谱
subplot(312)
plot(magFv)
title('Ricker子波的振幅谱'誉悔启)
angFv=angle(Fv)
subplot(313)
plot(angFv)
title('Ricker子波的相位谱')
helpdlg('欢迎采纳!有问题请继续庆如提问!谢谢','提醒')
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)