How can get the average between two array ?

R=[11.1665000000000 11.1665000000000 11.1665000000000 11.5708000000000 11.5708000000000 11.5708000000000 11.8082000000000 12.2129000000000 12.5798000000000 13.1573000000000 13.7489000000000 13.7489000000000 13.7489000000000 13.7489000000000 13.1573000000000]
G=[11.1398452590061 11.1398452590061 11.1746625281725 11.2582159351247 11.3603186339606 11.4574664588252 11.5600133540060 11.7028664353952 11.9332532074850 12.2362248163317 12.6259122359112 13.1153669304051 13.4784090511848 13.6622239221257 13.5801153987662 13.3312979619257]
I want to to get average first colume from array R with first col and second col from array R with second col with array G like this and get the output from. The output i should obtained 15 average from two array
like first col array R and first col array G =AVg
second col array R and second col array G =AVG
Third ........................................AVG
I have done it like
zz=R+G; Res=zz/2;
But, i want by using loop

답변 (2개)

Edson Alves
Edson Alves 2021년 5월 22일

2 개 추천

AVG = (R + G)/2;
It works well. No need of a "for" loop.
simone martinelli
simone martinelli 2016년 9월 28일
편집: simone martinelli 2016년 9월 28일

1 개 추천

for i=1:length(R)
avg1(i)=(R(i)+G(i))/2;
end

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

질문:

2016년 8월 22일

답변:

2021년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by