Hi I have data that has 5 sensors (columns). Is there an efficient way to do my code below in a "for loop"
max1 = max(sensors(:,2));
disp(max1);
max2 = max(sensors(:,3));
disp(max2);
max3 = max(sensors(:,4));
disp(max3);
max4 = max(sensors(:,5));
disp(max4);
max5 = max(sensors(:,6));
disp(max5);
%display min
min1 = min(sensors(:,2));
disp(min1);
min2 = min(sensors(:,3));
disp(min2);
min3 = min(sensors(:,4));
disp(min3);
min4 = min(sensors(:,5));
disp(min4);
min5 = min(sensors(:,6));
disp(min5);

 채택된 답변

Mathieu NOE
Mathieu NOE 2022년 1월 20일

0 개 추천

hi
sure it's possible
for ck = 1:5
max = max(sensors(:,ck));
disp(max);
end

댓글 수: 3

Alternative
for ck = 1:5
max(ck) = max(sensors(:,ck));
end
disp(max);
Michael Angeles
Michael Angeles 2022년 1월 22일
That didn't seem to work
Michael Angeles
Michael Angeles 2022년 1월 23일
Nevermind, it was the var max used...I changed it to something else.
Thanks,

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

추가 답변 (0개)

카테고리

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

질문:

2022년 1월 20일

댓글:

2022년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by