# How to compare elements of two different cell array?

1 ビュー (過去 30 日間)
Md. Golam Mostafa 2016 年 11 月 24 日

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 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 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'.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!