How to compare elements of two different cell array?
1 次查看(过去 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?
0 个评论
回答(1 个)
Ganesh Hegade
2016-11-24
You can use ismember function to compare two cells. https://de.mathworks.com/help/matlab/ref/ismember.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!