matrix if statement is above .5 then can I re enter it to show .5

조회 수: 2 (최근 30일)
cormac spillane
cormac spillane 2015년 4월 27일
답변: Thorsten 2015년 4월 27일
I have a large matrix(x) and I want to change any value the is above .5 or below -.5 to .5 or -.5 respectively in a certain column(2). any assistance regarding this topic would be greatly appreciated.
regards, cormac

채택된 답변

Guillaume
Guillaume 2015년 4월 27일
I'm sure it's covered in the Getting Started tutorials. It's basic matrix indexing.
A = rand(10, 10)*2-1; %create matrix between -1 to 1, for demo
A(A < -0.5) = -0.5;
A(A > 0.5) = 0.5

추가 답변 (1개)

Thorsten
Thorsten 2015년 4월 27일
R = randn(10)/3;
R(R > 0.5) = 0.5;
R(R < -0.5) = -0.5;

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by