MATLAB Code
%% TRM Demonstration (Simple & Clean)
clear; clc; close all;
%% PARAMETERS
numSymbols = 20; % number of BPSK symbols
samplesPerSymbol = 50; % oversampling
noiseStd = 0.02; % noise level
% multipath channel
h = [1 0.7 0.3];
%% TRANSMITTER
symbols = 2*(rand(1,numSymbols)<0.5)-1; % BPSK ±1
x = repelem(symbols, samplesPerSymbol); % oversample
%% FORWARD PROPAGATION
y = conv(x,h); % signal through channel
y = y + noiseStd*randn(size(y)); % add noise
%% TRM PROCESS
yTR = fliplr(y); % time reverse received signal
z = conv(yTR,h); % retransmit through same channel
%% ALIGN TRM SIGNAL
delay = length(h)-1;
zAligned = z(delay+1:delay+length(x));
% TRM produces reversed focus → flip again
zAligned = fliplr(zAligned);
%% SYMBOL RECOVERY
recovered = zeros(1,numSymbols);
for k = 1:numSymbols
idx = (k-1)*samplesPerSymbol + (1:samplesPerSymbol);
recovered(k) = sign(mean(zAligned(idx)));
end
%% PLOTS
figure
subplot(4,1,1)
plot(x,'b')
title('Transmitted BPSK Signal')
grid on
subplot(4,1,2)
plot(y,'r')
title('Received Signal (Multipath)')
grid on
subplot(4,1,3)
plot(zAligned,'g')
title('TRM Refocused Signal')
grid on
subplot(4,1,4)
stem(symbols,'b','filled')
hold on
stem(recovered,'r')
legend('Original','Recovered')
title('Symbol Comparison')
ylim([-1.5 1.5])
grid on
%% DISPLAY
disp('Original symbols:')
disp(symbols)
disp('Recovered symbols:')
disp(recovered)
Output
Original symbols:
-1 -1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 1 1 -1 -1
Recovered symbols:
-1 -1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 1 1 -1 -1