필터 지우기
필터 지우기

I am given an array

조회 수: 1 (최근 30일)
Diego Rosendo Pérez
Diego Rosendo Pérez 2021년 11월 30일
편집: Stephen23 2021년 12월 6일
Thank you very much in advance.
a = [3 4 5 3 64 7 6 34 8 5 4 3];
  댓글 수: 1
Stephen23
Stephen23 2021년 12월 6일
편집: Stephen23 2021년 12월 6일
Original question by Diego Rosendo Pérez retrieved from Google Cache:
I am given an array with different numbers and I have to compute the same array but with some values changed.
Hi, as you can see I am gven an initial array "a" and I have to create the code to return the same array but with some values changed according to some requirements I have to meet. Now, I have the values and their index but just do not know how to finish the exercise; I think that I need to use a for loop but I just do not know how to code the last line so that I obtain the same array "a" but with some values changed. Thank you very much in advance.
a = [3 4 5 3 64 7 6 34 8 5 4 3];
m = mean(a);
st = std(a);
an = abs(a - m) > st;
ind = find(an);

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

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 11월 30일
Do you mean:
a = [3 4 5 3 64 7 6 34 8 5 4 3];
m = mean(a);
st = std(a);
an = abs(a - m) > st;
ind = find(an);
a(ind) = an(ind)
  댓글 수: 1
Yongjian Feng
Yongjian Feng 2021년 11월 30일
편집: Yongjian Feng 2021년 11월 30일
This one?
a = [3 4 5 3 64 7 6 34 8 5 4 3];
m = mean(a);
st = std(a);
an = abs(a - m) > st;
ind = find(an);
a(ind) = 4 % replace all the meet the requirements with 4

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by