필터 지우기
필터 지우기

how to apply relational operators on matrix elements?

조회 수: 1 (최근 30일)
Dhines
Dhines 2013년 1월 11일
i=[1 2 3 -4;5 -7 8 9;5 6 7 -7;3 4 -2 4]; i want to replace the elements of above matrix with the value greater than 4 by 4, and the matrix elements less than -4 by -4.

채택된 답변

James Tursa
James Tursa 2013년 1월 11일
편집: James Tursa 2013년 1월 11일
i(i>4) = 4;
i(i<-4) = -4;
or
i = min(max(i,-4),4);
But in the future avoid i as a variable name since that is what MATLAB uses for the imaginary number sqrt(-1).

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by