2013-09-30 2 views
1

Matlab을 사용하여 사인 신호를 주파수 변조하려고합니다. 동일한 코드에 대해 다음 코드를 작성했습니다.MATLAB - FM 변조

fc = 5000; %Carrier Frequency 
fs = 1000; %Signal Frequency 
t = 0:0.00001:0.002; 
x = sin(2*pi*fs*t); 
dev = 50; 
subplot(2,1,1); 
plot(t,x); 
y = fmmod(x,fc,fs,dev); 
subplot(2,1,2); 
plot(t,y); 

두 번째가 아닌 첫 번째 플롯 명령을 표시 할 수 있습니다. 오류 : `fmmod' undefined near line 10 column 5이 표시됩니다. 위의 코드에서 잘못된 점은 무엇입니까?

+0

입니까? – Floris

+7

저는 Communications System Toolbox가없는 것으로 생각합니다. – Doresoom

+1

Doresoom은 "fmmod"의 일부인 Communications System Toolbox가 없을 것이라고 지적했습니다. MATLAB 명령 행에'ver'을 입력하여 도구 상자를 확인할 수 있습니다. – am304

답변

2

다음 함수는 FM 변조 된 신호를 생성합니다. fmmod처럼 좋지 않지만 (유연성있는 등) Comm System Toolbox가없는 경우이 방법이 좋습니다.

function [s t] = makeFM(x, Fc, Fs, strength) 
% for a signal x that modulates a carrier at frequency Fc 
% produce the FM modulated signal 
% works for 1 D input only 
% no error checking 

x = x(:); 

% sampling points in time: 
t = (0 : numel(x) - 1)'/Fs; 

% integrate input signal 
integratedX = cumsum(x)/Fs; 
s = cos(2 * pi * (Fc * t + strength * integratedX)); 

는 경로에이를 넣고 (선택적 매개 변수 만 제외) fmmod 함수와 유사 인수를 호출

fc = 5000; %Carrier Frequency 
fs = 1000; %Signal Frequency 
t = 0:0.00001:0.002; 
x = sin(2*pi*fs*t); 
dev = 50; 
subplot(2,1,1); 
plot(t,x); 
y = makeFM(x, fc, 2.5*fc, dev); % note sampling frequency must be > carrier frequency! 
subplot(2,1,2); 
plot(t,y); 

당신을 위해 작동하는 방법을 알려주세요. 내 생각

0

이 더 간단한 접근 방법은`fmmod`을 정의 않았다/

clc; 
clear all; 
close all; 
fm=input('Message Frequency='); 
fc=input('Carrier Frequency='); 
mi=input('Modulation Index='); 
t=0:0.0001:0.1; 
m=sin(2*pi*fm*t); 
subplot(3,1,1); 
plot(t,m); 
xlabel('Time'); 
ylabel('Amplitude'); 
title('Message Signal'); 
grid on; 

c=sin(2*pi*fc*t); 
subplot(3,1,2); 
plot(t,c); 
xlabel('Time'); 
ylabel('Amplitude'); 
title('Carrier Signal'); 
grid on; 

y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));%Frequency changing w.r.t Message 
subplot(3,1,3); 
plot(t,y); 
xlabel('Time'); 
ylabel('Amplitude'); 
title('FM Signal'); 
grid on;