For loop alternative method

조회 수: 3 (최근 30일)
Dharmesh Joshi
Dharmesh Joshi 2022년 8월 31일
댓글: Torsten 2022년 8월 31일
Hi
Instead of using a long for loop and if statement, is there alternative method of anylsing a array to on display values which are above or below a certain limit?
For example when sensor is above certain value?
  댓글 수: 2
Stephen23
Stephen23 2022년 8월 31일
Logical indexing.
Dharmesh Joshi
Dharmesh Joshi 2022년 8월 31일
Is there any example
For example i have two arrays
SensorA
And
Temperture.
I would like to find all points in SensorA when temperure is below 30 degrees, and then using that data to preform mean, mode ,etc.

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

채택된 답변

Torsten
Torsten 2022년 8월 31일
이동: Matt J 2022년 8월 31일
SensorA_under_30_degrees = SensorA(Temperature<30)
  댓글 수: 2
Dharmesh Joshi
Dharmesh Joshi 2022년 8월 31일
편집: Dharmesh Joshi 2022년 8월 31일
Thanks
I will try that.
At the momment i am using:
temp_ind=find(iot_temperture < 30);
no2_comp = iot_no2_we_voltage(temp_ind);
Torsten
Torsten 2022년 8월 31일
And you get an error message ?
Then maybe iot_no2_we_voltage and iot_temperture don't have the same length.
(Shouldn't it be "iot_temperature" instead of "iot_temperture" or did you want to save a character in writing ?)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by