Filter löschen
Filter löschen

How to check that the value is within the spec

2 Ansichten (letzte 30 Tage)
Mekala balaji
Mekala balaji am 4 Aug. 2016
Bearbeitet: Swarooph am 4 Aug. 2016
Hi,
I have two tables (1) Data table, (2) Spec Table(includes lower & upper limit). First row shows Variable name (A,B,C,D,E) for the same I have the spec table. Here, NA represents spec not defined,and if a variable value is not double just report (NA). I want to do
1. If the status is Fail, then check the corresponding variables (their value) is within the spec or not, if it is in the spec then report OK, else report Out.My output table is shown.Many thanks in advance.
Data table:
Status A B C D E
Success -0.5 9 2 Positive 12
Fail 7 11 23 Positive 3
Success 1 9 18 Deflect 6
Success 1.3 3 15 Positive 12
Fail -6 6 -1 Negative 1
Success 0.8 4 11 Positive 25
Fail 3 9 26 Positive 30
Spec table:
Lower Upper
A -1.5 1.5
B NA NA
C 0 20
E 5 25
Output:
A B C D E
OK NA OK NA OK
Out NA Out NA Out
OK NA OK NA OK
OK NA OK NA OK
Out NA Out NA Out
OK NA OK NA OK
Out NA Out NA Out

Akzeptierte Antwort

Swarooph
Swarooph am 4 Aug. 2016
Bearbeitet: Swarooph am 4 Aug. 2016
  1. I suggest you convert the above tables first to actual MATLAB table variables.
  2. Use categorical to tell the Status column is from a finite set of Success of Fail.
  3. Finally use logical indexing with the categorical variable (to dig into only rows that are Success or Fail). You can use logical indexing to perform relational operators (Such as <, >, >= etc.) to find if the Spec table is then satisfied or not.
  4. Take a look at this example that explains a similar workflow.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by