필터 지우기
필터 지우기

Multiply values in array by *-1

조회 수: 2 (최근 30일)
Edward Keavney
Edward Keavney 2022년 7월 28일
댓글: Edward Keavney 2022년 7월 28일
Hi,
I have an array 1X106. I want to be able to multiply specific entries in the array by -1.
e.g., multiplying the 16, 17 and 18 value in the array by -1 whilst still keeping the remainder of the array with the original values.
Any help would be greatly appreciated,
Thanks!

채택된 답변

Chunru
Chunru 2022년 7월 28일
a = randn(1, 106);
a(14:20)
ans = 1×7
0.8401 1.6024 1.0470 -1.1157 0.2066 -2.0192 -0.6220
a(16:18)=-a(16:18);
a(14:20)
ans = 1×7
0.8401 1.6024 -1.0470 1.1157 -0.2066 -2.0192 -0.6220
  댓글 수: 1
Edward Keavney
Edward Keavney 2022년 7월 28일
Perfect, thank you very much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by