필터 지우기
필터 지우기

Compare each element of a vector with a number and if the element of the vector is higher than the number then replace that element with the number

조회 수: 3 (최근 30일)
Suppose we have a vector Av=[5;4;6.7;5.5;12;5.4;7]
I want to check that the each element of Av should not more than the 6.
if vector element is more than the 6 then replace that element of the vector Av with 6.
please help me how can i write the command for it?

채택된 답변

DGM
DGM 2023년 1월 5일
Like so
Av=[5;4;6.7;5.5;12;5.4;7]
Av = 7×1
5.0000 4.0000 6.7000 5.5000 12.0000 5.4000 7.0000
Av = min(Av,6)
Av = 7×1
5.0000 4.0000 6.0000 5.5000 6.0000 5.4000 6.0000

추가 답변 (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