Replace values in a matrix
이전 댓글 표시
Hello. I have the following problem.
I have a matrix A with dimensions 1X72. I want in matrix B to have the mean per 24 values. That is, matrix B should be 1X3. Next, I want those values in matrix A above 50 to be replaced by the mean. That is, any value in positions A (1:24) above 50 to be replaced by the mean found in B (1), any value in positions A (25:48) exceeding 50 to be replaced by the mean located in B (2) and any value in positions A (49:72) exceeds 50 to be replaced by the mean in B (3).
Your help is invaluable !!!
댓글 수: 5
KSSV
2021년 8월 4일
What have you attempted?
stelios loizidis
2021년 8월 4일
Rik
2021년 8월 4일
If you show your code it is probably easy to modify it to do the replacement.
In the mean time a hint:
a=[1 5 2];
a([false true false])=10
%now a is [1 10 2]
stelios loizidis
2021년 8월 4일
Rik
2021년 8월 4일
Since you seem to be prepared to hard-code the indices: can you think of a way to use my hint to solve your own question?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!