How to read an array?

조회 수: 2 (최근 30일)
Shraddha Joshi
Shraddha Joshi 2016년 5월 4일
편집: Shraddha Joshi 2016년 5월 4일
Suppose I have an Array called Heart_Rates containing a few values in it. And I have written following code to read it and categorize its elements and display only their file names.
for b=1:length(Heart_Rates)
if Heart_Rates(b)>=60 || Heart_Rates(b)<=80
Normal(1,:)=filenames{b};
elseif Heart_Rates(b)>80 || Heart_Rates(b)<100
Abnormal(1,:)=filenames{b};
else Heart_Rates(b)>=100
Atrial_Fibrillation(1,:)=filenames{b};
end
end
But I am not getting the proper output. Can u please tell me what is the proper code to correct it?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 5월 4일
mask = Heart_Rates(b)>=60 || Heart_Rates(b)<=80;
Normal = filenames(mask);
mask = Heart_Rates(b)>80 || Heart_Rates(b)<100;
Abnormal = filenames(mask);
mask = Heart_Rates(b)>=100;
Atrial_Fibrillation = filenames(mask);
Question: what are you going to do for heart rates below 60?
  댓글 수: 1
Shraddha Joshi
Shraddha Joshi 2016년 5월 4일
편집: Shraddha Joshi 2016년 5월 4일
Heart_Rates below 60 are also categorized as abnormal. And I tried with the code u suggested
for b=1:length(Heart_Rates) mask = Heart_Rates(b)>=60 Heart_Rates(b)<=80; Normal = filenames(mask); mask = Heart_Rates(b)>80 Heart_Rates(b)<100; Abnormal = filenames(mask); mask = Heart_Rates(b)>=100; Atrial_Fibrillation = filenames(mask); end
But I am not able to get the proper output. In fact it is not reading that Heart_Rates array at all. Could you please tell me where is the mistake and how to correct it?

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

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by