Generating signals
조회 수: 20 (최근 30일)
이전 댓글 표시
I have been away from Matlab for awhile and will need to refresh myself. In the mean time I could use a little help getting restarted. I need analyze an output signal that consists of a binary signal that is added to a two tone interference signal.
The binary signal is; +1 for one unit of time starting a zero, -1 for two units of time then +1 for one unit of time, -1 for one unit of time and and finally +1 for one unit of time.
The interference signal is; .7cos(6pit)+.5cos(9pit+pi/4)
How would I go about generating these two signals, then adding them together? Thanks
댓글 수: 0
답변 (3개)
Arturo Moncada-Torres
2011년 9월 1일
I assume that your binary signal is periodic (+1, -1, +1, -1, ...). You would have to do something like this:
% Sampling characteristics.
fs = 1000; % [Hz]
Ts = 1/fs; % [s]
t = 0 : Ts : 10-Ts; % Time vector.
% Signals' amplitudes.
a1 = 0.7;
a2 = 0.5;
% Signals' frequencies [rad].
f1 = 6*pi;
f2 = 9*pi;
% Signals' phase [rad].
theta1 = 0;
theta2 = pi/4;
% Create the signals.
signal1 = a1 * cos((f1.* t) + theta1);
signal2 = a2 * cos((f2.* t) + theta2);
signal = signal1 + signal2;
% Create noise.
noise = zeros(1, numel(t));
for ii = 1:numel(noise)
if mod(ii, 2) == 0
noise(ii) = 1;
elseif mod(ii, 2) == 1
noise(ii) = -1;
end
end
% Pollute signal.
signalNoise = signal + noise;
% Plots
figure();
subplot(3,1,1);
plot(t, signal1);
ylim([-1.5 1.5]);
subplot(3,1,2);
plot(t, signal2);
ylim([-1.5 1.5]);
subplot(3,1,3);
plot(t, signal);
ylim([-1.5 1.5]);
figure();
subplot(3,1,1);
plot(t, noise);
ylim([-1.5 1.5]);
subplot(3,1,2);
plot(t, signal);
ylim([-1.5 1.5]);
subplot(3,1,3);
plot(t, signalNoise);
ylim([-1.5 1.5]);
Try it and let me know if it works.
댓글 수: 0
Walter Roberson
2011년 9월 1일
resolution = 20;
oneunit = ones(1,resolution);
binarysignal = [oneunit, -oneunit, -oneunit, oneunit, -oneunit, oneunit];
t = ((1 : length(binarysignal)) - 1) ./ resolution;
interference = 0.7*cos(6*pi*t) + 0.5 * cos(9*pi*t + pi/4);
totalsignal = binarysignal + interference;
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!