How to check upper and lower limits

조회 수: 2 (최근 30일)
Kanakaiah Jakkula
Kanakaiah Jakkula 2018년 5월 24일
답변: Ameer Hamza 2018년 5월 26일
Hi,
I have below actual data and its spec limits, and I want to check whether the actual data is with in the spec limit or not:
Vactual(Actual values):
v1 -4
v2 2.3
v2 11
Vspecs:
UupperLimit LowerLimit
v1 -3.0 5
v2 2.0 3.5
v3 4.5 8.0
If the actual value <lower limit, then the actual value will become the lower limit value, and if it is higher than the upper limit then the actual value will become the upper limit.
My desired output is:
v1 -3
v2 2.3
v2 8

답변 (1개)

Ameer Hamza
Ameer Hamza 2018년 5월 26일
Try this
v = [-4;
2.3;
11];
vLow = [-3;
2;
4.5];
vHigh = [5;
3.5;
8];
v(v<vLow) = vLow(v<vLow);
v(v>vHigh) = vHigh(v>vHigh);
v =
-3.0000
2.3000
8.0000

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by