I am new to MATLAB, can anyone help to generate for loop to assign array elements iteratively
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to generate a for loop to display the elements of the sequence whose indices are specified in the arrays "usedFrequencies" and "unusedFrequencies". (For "usedFrequencies" display '1' for each of the elements), (For "unusedfrequency", display '0' for each of the elements). Find the codes below
%% Parameters
T = 600;
PRB = 6;
M = 4;
snr = 15;
n_bits = log2(M);
% % RF_spectrum = cell(PRB, T);
RF_spectrum = zeros(PRB, T);
for t = 1:1:T
usedFrequencies = [1, 3, 5];
unusedFrequencies = [2, 4, 6];
for f = 1:1:length(usedFrequencies)
RF_spectrum(usedFrequencies(1,f),t) = PU_signal_rx(t,1);
RF_spectrum(unUsedFrequencies(1,f),t) = noise_signal;
end
clear noise_signal
end
댓글 수: 1
Walter Roberson
2022년 3월 22일
You do not assign to noise_signal anywhere, but you clear it. You might have had a noise_signal already existing, but after one iteration of t you clear it, so you cannot complete the second iteration of t
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Beamforming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!