Files
ARSS/01. Tx Path/apply_mimo_mode.m
T

31 lines
1.3 KiB
Matlab

% 입력 변수에서 chirpIdx 제거, t와 fs 추가
function tx_matrix = apply_mimo_mode(x_amp, t, Timing, NumTx, mimoMode, fs)
N_samples = length(x_amp);
tx_matrix = zeros(NumTx, N_samples);
T_chirp = Timing.IdleTime + Timing.RampEndTime;
SamplesPerChirp = round(T_chirp * fs);
% [핵심]: 각 샘플이 몇 번째 처프(1, 2, 3...)에 해당하는지 배열로 계산
chirp_indices = floor((0:N_samples-1) / SamplesPerChirp) + 1;
switch upper(mimoMode)
case 'TDM'
% 처프 인덱스에 따라 1,2,3,1,2,3 번갈아가며 안테나 켬
active_tx_seq = mod(chirp_indices - 1, NumTx) + 1;
for tx = 1:NumTx
% 활성화된 안테나 번호와 일치하는 구간만 신호 통과
tx_matrix(tx, :) = x_amp .* (active_tx_seq == tx);
end
case 'DDMA'
% 모든 처프에서 켜지지만 처프 번호에 따라 위상이 누적해서 틀어짐
for tx = 1:NumTx
phase_shift_seq = 2 * pi * (tx - 1) * (chirp_indices - 1) / NumTx;
tx_matrix(tx, :) = x_amp .* exp(1j * phase_shift_seq);
end
otherwise
error('지원하지 않는 MIMO 모드입니다. TDM 또는 DDMA를 선택하세요.');
end
end