How to compare elements of two different cell array?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Ganesh Hegade
am 24 Nov. 2016
You can use ismember function to compare two cells. https://de.mathworks.com/help/matlab/ref/ismember.html
1 Kommentar
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!