How to eliminate value at each position required
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have an array of matrix in the a=cell (1,16). Each of the array matrix in the cell is equal to 128x128. Then, I did the multiplication between each of column of the cell so that I can get a pair projection of 128x128 of each matrix. I.e: E{i,j}. Thus, I will get E{1,2}, E{1,3}..till..E{16,16} and each of E{i,j} has 128x128 array matrix.
From each of the pair projection, I want to eliminate the value at certain position in the 128x128 matrix. For example, at position (31,119), (13,102), (98,10) and (11,27)in each pair projection of E{i,j}, I want the value becomes zero.
how can I write the code? Can anybody guide how to write a correct code for this function. I have tried to write the code but it consists an error.
load('EveryProjectionNormDEliminateSpike_max_same_v2.mat');
% ---------- Dot product to get each pairing projection -----------
i=1;
for i=1:16;
m1=EachProj_EliminateSpike_MaxSpike_v2{1,i};
for j=1:16
m2=EachProj_EliminateSpike_MaxSpike_v2{1,j};
c=m1.*m2; % Do the element multiplication to get Ei,j
E{i,j}=c;
end
end
% eliminate position has spike equal to zero
for i=1:16;
for j=1:16;
for Tx=1:128;
for Rx =1:128;
if E{i,j}(Rx,Tx)= E{i,j}(31,119);E{i,j}(31,119)=0;end
if E{i,j}(Rx,Tx)= E{i,j}(98,10);E{i,j}(98,10)=0;end
end
end
end
end
댓글 수: 0
답변 (1개)
MHN
2016년 2월 20일
편집: MHN
2016년 2월 20일
for i=1:16;
for j=1:16;
for Tx=1:128;
for Rx =1:128;
if E{i,j}(Rx,Tx)==E{i,j}(31,119)
E{i,j}(31,119)=0;
end
if E{i,j}(Rx,Tx)==E{i,j}(98,10)
E{i,j}(98,10)=0;
end
end
end
end
댓글 수: 1
MHN
2016년 2월 20일
There are more efficient way rather than 4 nested loop, but I just corrected your code.
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!