If then on column based upon number
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone and I'll preface a thank you for any help I receive:
I have 0 code experience but am attempting to run some data in new lab I'm working in and could really use the help. I am attempting to simply average a set of numbers in a column based upon data from another column in an "if then" sense, I believe. I will attempt to explain below:
Column A; Column B:
0 90
0 45
0 45
0 45
1 55
2 65
3 75
4 80
I wish to average the the #'s in column B based upon the #'s in column A such as once column A reaches 4 it avearges the data up to (and excluding) data in row 1 (i.e. 65, 75, 80)
Sorry if this is a poor explenation - any insight would be greatly appreciated.
Thanks,
댓글 수: 2
Walter Roberson
2021년 7월 9일
Is it correct that any rows in which column A are <= 1 are to be ignored?
Is it correct that for any rows in whcih column A are > 1, that you want a "cumulative mean" -- so for the 2 entry you would mean(65), for the 3 entry you would mean([65 75]), for the 4 entry you would mean([65 75 80]) ?
If that is the case, then if there were then additional rows that had <= 1, then should the "cumulative mean" reset, or should it keep going as if those rows were not there?
For example, if after your current data there were
1 85
2 90
then should the 1 line be quietly ignored, or should it result in the mean for 2 being mean(90) -- cumulative mean only during the "runs" of values?
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!