필터 지우기
필터 지우기

array multiplication with a negative value

조회 수: 3 (최근 30일)
Bathrinath
Bathrinath 2014년 6월 11일
댓글: Bathrinath 2014년 6월 11일
A=[0,-2.2,-3.3,-25;1.2,0,-1.1,12;2,-8,8,0] my answer is to be A=[0,-2.2,-3.3,-25;-1.2,0,-1.1,-12;-2,-8,-8,0]. I need to convert the values in A which is greater than zero as -A. I have used if A(A > 0) A=-A; end This is not working. Suggest some points

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 6월 11일
편집: Andrei Bobrov 2014년 6월 11일
t = A > 0;
A(t) = -A(t);
or
A = -abs(A);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by