필터 지우기
필터 지우기

How to compare elements of two different cell array?

조회 수: 3 (최근 30일)
Md. Golam Mostafa
Md. Golam Mostafa 2016년 11월 24일
편집: Md. Golam Mostafa 2016년 11월 25일
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에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by