How to compare elements of two different cell array?

6 次查看(过去 30 天)
I have a cell array named binData=cell(d,s,h) and every cell binData{d,s,h} has 500-by-8 elements. Values of the 8th column are signal power.
I have another cell array named threshold=cell(d,s,h) and every cell threshold{d,s,h} has 1 element. This is my receiver threshold.
Now, I have to find how many of the values 500 elements of the 8th column of binData{d,s,h} is less than equal to the value of the element of threshold{d,s,h}. The process will then be repeated for all cells. I mean first comparison with binData{1,1,1} with threshold{1,1,1}, second with binData{1,2,1} with threshold{1,2,1}...and so on till binData{630,28,26} with threshold{630,28,26}.
I have run the following code:
m=1;n=500;
for h=1:26;
for d=1:630;
for s=1:28
fr=0; occ=0;
pp(s)=m+(s-1)*500;
qq(s)=n+(s-1)*500;
binData{d,s,h}=fileData{h,d}(pp(s):qq(s),:);
sortedfdstr{d,s,h}=sort(binData{d,s,h}(:,8));
noisefloor{d,s,h}=mean(sortedfdstr{d,s,h}(1:30));
threshold{d,s,h}=noisefloor{d,s,h}+10;
C=le(binData{d,s,h}(:,8),threshold{d,s,h});
P=numel(binData{d,s,h}(:,8));
for kk=1:(P-2)
if C(kk,1)==1 && C(kk+1,1)==1 && C(kk+2,1)==1
fr=fr+1;
else
occ=occ+1;
end
end
free{d,s,h}=fr; occu{d,s,h}=occ;
percent{d,s,h}=free{d,s,h}/(free{d,s,h}+occu{d,s,h});
end
end
end
I expect to get a total of 630*28*26 elements of cell array free{d,s,h} but it is returning a blank cell array.
Can anyone help me out?

回答(1 个)

Ganesh Hegade
Ganesh Hegade 2016-11-24
You can use ismember function to compare two cells. https://de.mathworks.com/help/matlab/ref/ismember.html
  1 个评论
Md. Golam Mostafa
Md. Golam Mostafa 2016-11-25
编辑:Md. Golam Mostafa 2016-11-25
No, I have to find the elements of binData that are equal to or below the threshold value. The problem is solved. I have miss placed the following portion of the code:
free{d,s,h}=fr;
occu{d,s,h}=occ;
percent{d,s,h}=free{d,s,h}/(free{d,s,h}+occu{d,s,h});
This will go after the next 'end'.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by