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!