gpt4 book ai didi

matlab - gnu-octave 方波载波的正弦 FM 调制

转载 作者:行者123 更新时间:2023-12-05 07:58:40 29 4
gpt4 key购买 nike

我在 Octave 中使用以下代码来实现正弦消息和方波载波的频率调制。

%script to make a squarewave carrier modulated with a sinusoidal message
fmsg=1; %Message signal frequency. 1 Hz
fc=10; %carrier frequency, 10 Hz
Fs=200; %sampling frequency, 200 Hz
t=[0:1/Fs:3/fmsg]; %Time duaration defined


%The message signal
x=2.*sin(2*pi*fmsg*t);
subplot(3,1,1); plot(t,x); title('Message')

%The carrier signal
y=5.*square(2*pi*fc*t);
subplot(3,1,2);plot(t,y); title('Carrier')

%steps for FM modulation
x_max=max(x);
x_modulating=x./x_max; %x_modulating is normalized to unity
fdev=x_modulating*fc/2; %finding frequency deviation corresponding to a maximum of 50% deviation from the carrier frequency
fc=fc*ones(size(t)); %making the size of fc and fdev the same so that they can be added
z=5.*square(2*pi*((fc+fdev).*t)); %Generating FM signal
subplot(3,1,3);plot(t,z);title('FM');
print('fm.png');

但由此产生的 FM 波形的频率与消息信号幅度不成比例。可能是什么原因。如何解决?

最佳答案

来自 wikipedia ,调频信号的相位与瞬时频率的积分成正比,这与瞬时频率乘以运行时间不太一样。

可以通过修改您提供的代码的最后一部分来实现简单的阶段集成,例如:

% fc = fc*one(size(t)); % will use scalar fc for all i below
phase = 0;
for i=1:size(t,2)
z(i) = 5.*square(phase);
phase = mod(phase + 2*pi*(fc+fdev(i))/Fs, 2*pi);
endfor

请注意,由于调制信号在采样周期内会发生变化,因此您可以使用梯形积分器获得稍微更准确的积分,但以上内容对于大多数应用来说应该足够了。

关于matlab - gnu-octave 方波载波的正弦 FM 调制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23931723/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com