Clear Filters
Clear Filters

How to find the average in for loop?

2 views (last 30 days)
Jiyeon Jang
Jiyeon Jang on 20 May 2021
Commented: Jiyeon Jang on 20 May 2021
for j = 1 : 1 : 10
Ry = max(Y(160 * (j-1) + 1:160*j)) + abs(min(Y(160 * (j-1) + 1:160*j)));
end
In this code, How to find the average of Ry in for loop?

Answers (1)

KSSV
KSSV on 20 May 2021
avg = 0 ;
for j = 1 : 1 : 10
Ry = max(Y(160 * (j-1) + 1:160*j)) + abs(min(Y(160 * (j-1) + 1:160*j)));
avg = avg + Ry ;
end
avg = avg/j ;

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!