Hello,
I have two variables with dimensions 195414 x 1, FeatureDrag and TopDrag
I am getting different results when I calculate the mean of the percent difference between the two variables. Anyone spot an issue I seem to be blind to?
Approach 1:
Drag_reduction_instant = (FeatureDrag-TopDrag)./TopDrag;
DR1 = mean(Drag_reduction_instant, "all")*100;
Approach 2:
TD_Final = mean(TopDrag, "all"); %Top Drag, mean of whole dataset
FD_Final = mean(FeatureDrag, "all"); %Feature Drag, mean of whole dataset
DR2 = (FD_Final-TD_Final)/TD_Final*100; % these two should be identical

 채택된 답변

Torsten
Torsten 2023년 5월 2일
이동: Torsten 2023년 5월 2일

0 개 추천

It's obvious that mean(x/y) does not equal mean(x)/mean(y) for arrays x and y. Test it for a simple example.

댓글 수: 1

Ben Hamilton
Ben Hamilton 2023년 5월 2일
Thank you for pointing that out. I guess I have never come across this before and will have to do some more reading.

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

추가 답변 (0개)

제품

릴리스

R2022a

태그

질문:

2023년 5월 2일

댓글:

2023년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by