How to eliminate value at each position required

2 views (last 30 days)
yasmin
yasmin on 20 Feb 2016
Commented: MHN on 20 Feb 2016
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

Answers (1)

MHN
MHN on 20 Feb 2016
Edited: MHN on 20 Feb 2016
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 Comment
MHN
MHN on 20 Feb 2016
There are more efficient way rather than 4 nested loop, but I just corrected your code.

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!