nested for loop for 2d matrix cell
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a cell RDM {1x10} and every cell contains (512x1024) matrix. Now i have applied the following algorithm on one Matrix which i have to apply on all the matrix.
I get error on indexing every time. How can i implement that for all 10 matrices?
Tr = 10;
Td = 8;
Gr = 4;
Gd = 4;
% offset the threshold by SNR value in dB
offset = 1.4;
for i = Tr+Gr+1:(fft_size/2)-(Gr+Tr)
for j = Td+Gd+1:fft_size-(Gd+Td)
noise_level = zeros(1,1);
for p = i-(Tr+Gr) : i+(Tr+Gr)
for q = j-(Td+Gd) : j+(Td+Gd)
if (abs(i-p) > Gr || abs(j-q) > Gd)
noise_level = noise_level + 10.^(RDM(p,q)/10);
end
end
end
threshold = 10*log10(noise_level/(2*(Td+Gd+1)*2*(Tr+Gr+1)-(Gr*Gd)-1));
threshold = threshold + offset;
CUT = RDM(i,j);
if (CUT < threshold)
RDM(i,j) = 0;
else
RDM(i,j) = 1;
end
end
end
댓글 수: 0
답변 (1개)
Abdolkarim Mohammadi
2020년 5월 22일
편집: Abdolkarim Mohammadi
2020년 5월 22일
I think the problem lies here
CUT = RDM(i,j);
if (CUT < threshold{o})
You said that RDM is a cell matrix; so CUT is also a cell matrix because it has been assigned using parantheses, not curly braces. But threshold{o} is double because you used implicit casting using curly braces. If this is the problem, then you must use
CUT = RDM{i,j};
This makes CUT a double and the comparison in the following line becomes possible.
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!