필터 지우기
필터 지우기

replacing a element of an array and show them in certain way.

조회 수: 1 (최근 30일)
Halsey Hal
Halsey Hal 2021년 7월 24일
댓글: John D'Errico 2021년 7월 24일
If i want a output of an array like a=[4 -6 0 2 5 0 -6]. if I want to replace all the values to that are positive to 1 and print like a[0]= 1, a[1]= -6, a[2]= 0, a[3]= 1,..... and so on. what whould be tha code.

답변 (1개)

Chunru
Chunru 2021년 7월 24일
a=[4 -6 0 2 5 0 -6]
a = 1×7
4 -6 0 2 5 0 -6
a(a>0) = 1;
a
a = 1×7
1 -6 0 1 1 0 -6
  댓글 수: 3
Chunru
Chunru 2021년 7월 24일
Try it out yourself first.
John D'Errico
John D'Errico 2021년 7월 24일
@Halsey Hal - Sorry, but Answers is not here to do homework assignments for people. This problem was given to you, so you would spend some time thinking about how to form strings composed of pieces for output, not so you would get the answer written for you online.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by