Hi guys! I use the find command but it does not return what I expect.
for i=1:9:500
c=c+1;
d=find(Horizon{i:i+9,8} <= 2);
m=mean(Horizon{i:i+9,8});
report12{c,7}=m;
%if isnan(m)==0
%report12{c,1}=Horizon{i,1};
%report12{c,2}=Horizon{i+9,1};
end
For any value of i and then i+9 my d is always equal to: d= [1,2,3,4,5,6,7,8,9,10,11], of course if each value verifies the condition. What I really expect is filling d with the Horizon row index. let 's say:
d=find(Horizon{440:450,8} <= 2);
d=[440, 441,445,450] assuming only 4 values verifiy the condition

댓글 수: 4

David Hill
David Hill 2021년 6월 16일
I am not following you. Provide and example of your Horizon cell array and your desired output during an iteration of your loop.
Here there is a subset of Horizon.
1 step :
d=find(Horizon{1:10,8} <= 2);
d=0x0
2- step:
d=find(Horizon{11:20,8} <= 2);
d= [1,2,3,4,5,6,7,8,9,10] but I'm looking for d= [11, 12,13,14,15,16,17,18,19,20]
Stephen23
Stephen23 2021년 6월 16일
편집: Stephen23 2021년 6월 16일
Excel worksheets are not a particularly reliable way to transfer data. Save and MATLAB data without loss of precision using a .mat file.
How are you importing the Excel file data into MATLAB?
Riccardo Tronconi
Riccardo Tronconi 2021년 6월 16일
In matlab is an output of another function so I have it .mat.
Instead of 20 rows in this subset are 16 but the logic behind it is the same:
  1. 1:8
  2. 9:16

댓글을 달려면 로그인하십시오.

 채택된 답변

Steven Lord
Steven Lord 2021년 6월 16일

0 개 추천

Please provide a small sample of the Horizon variable from where you expected the find call to return data but it does not. My suspicion is that the elements in that section of Horizon display as 2 but the stored values are actually slightly larger than 2.
format % default display format
x = 2.000000001 % displays as 2
x = 2.0000
x <= 2 % but is not less than or equal to 2
ans = logical
0

댓글 수: 1

Riccardo Tronconi
Riccardo Tronconi 2021년 6월 16일
Thanks for your time. You can find a better explanation above :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by