Ouput value manupulation?

조회 수: 2 (최근 30일)
Azad Khandoker
Azad Khandoker 2019년 7월 29일
답변: Azad Khandoker 2019년 7월 29일
I have got different values ​​from a certain calculation,
Where x = (0.5, 0.70, -0.81, -0.90)
I want to get read of the minus values ​​and replace with '0', I am doing like-
x (3) = 0; % x (3) is the position of the value in the specific column
x (4) = 0; % x (4) is the position of the value in the specific column
Now I am having x = (0.5, 0.70, 0, 0)
So, my question is there any other possible way do that? i, e with functions or limits

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 7월 29일
편집: Andrei Bobrov 2019년 7월 29일
x_new = x.*(x > 0);
or
x_new = x;
x_new(x_new <= 0) = 0;
or
xnew = max(x,0);

추가 답변 (1개)

Azad Khandoker
Azad Khandoker 2019년 7월 29일
Great .... Thank you

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by