⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ee160part1.m

📁 differen modulation scheme simulation in matlab.
💻 M
字号:
%part a
clear all;
close all;
fc= 2000; % carrier frequency (Hz)
fs = 22050; % sample frequency (Hz)
d = 1.0; % duration of the signal (s)
n = fs * d; % number of samples
s = (1:n) / fs; % sound data preparation
signal = sin(2 * pi * fc * s); % sinusoidal signal
figure(1)
plot(s,signal,'r');xlabel('Duration of the signal'),ylabel('Amplitude');
axis([0 0.01 -2 2]);
hold on;
%sound(signal, fs); % listen to the tone
WAVWRITE(signal,fs,16,'wave1'); %writes data stored in signal to wave file called 'wave1'
%for fc=200
fc1=200;%carrier frequency (Hz)
signal1=sin(2*pi*fc1*s);
%sound(signal1,fs);
WAVWRITE(signal1,fs,16,'wave2');  %writes data stored in signal to wave file called 'wave2'
plot(s,signal1,'o');
%for fc=4000
fc2=4000;%carrier frequency (Hz)
signal2=sin(2*pi*fc2*s);
%sound(signal2,fs);
WAVWRITE(signal2,fs,16,'wave3');  %writes data stored in signal to wave file called 'wave3'
plot(s,signal2,'g');legend('fc=2000','fc=200','fc=4000');
hold off;

%part b
fs = 22050; % sample frequency (Hz)
d = 1.0; % duration of the signal (s)
n = fs * d; % number of samples
s = (1:n) / fs; % sound data preparation
mean = 0; % mean of the noise
sigma2 = 1; % variance (power) of the noise
noise = sqrt(sigma2)*randn(1,n)+mean; % noise signal
%sound(noise, fs) % listen to the noise
figure(2)
plot(s,noise);
axis([0 0.01 -2 2]);
%comment as you decrease the sampling frequency ,you will hear low pitch
%sound.

%part c
signal_noise=noise+signal1;
sound(signal_noise,fs);
WAVWRITE(signal_noise,fs,16,'wave4');  %writes data stored in signal to wave file called 'wave4'
figure(3)
subplot(1,2,1),plot(s,signal1);xlabel('Duration of the signal'),ylabel('Amplitude of the signal'),title('sinusodial signal,fc=200 Hz');
axis([0 0.01 -2 2]);
subplot(1,2,2)
plot(s,signal_noise);xlabel('Duration of noisy signal'),ylabel('Amplitude of noisy signal');
title('Noisy sinusodial signal,noise power=1,fc=200 Hz');
axis([0 0.01 -2 2]);
%comment: as you add noise to sinusodial signal , you will hear noisy
%sinusodial.

%for different noise power
sigma3=.1;
noise1=sqrt(sigma3)*randn(1,n)+mean; %noise signal
signal_noise1=signal1+noise1; %noisy sinusodial ,fc=200 Hz ,noise power=0.1
sigma4=0.01;
noise2=sqrt(sigma4)*randn(1,n)+mean; %noise signal
signal_noise2=signal1+noise2; %noisy sinusodial ,fc=200 Hz, noise power=0.01
figure(4)
subplot(1,2,1),plot(s,signal_noise1),xlabel('Duration of the noisy signal'),ylabel('Amplitude of the noisy signal');
title('Noisy signal with noise power=0.1,fc=200 Hz');axis([0 0.01 -2 2]);
subplot(1,2,2),plot(s,signal_noise2),xlabel('Duration of the noisy signal'),ylabel('Amplitude of the noisy signal');
title('Noisy signal with noise power=0.01,fc=200 Hz');axis([0 0.01 -2 2]);
%comment:As you reduce noise power,you will get less noisy signal.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -