- I suggest you convert the above tables first to actual MATLAB table variables.
- Use categorical to tell the Status column is from a finite set of Success of Fail.
- 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.
- Take a look at this example that explains a similar workflow.
How to check that the value is within the spec
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Swarooph
2016-8-4
编辑:Swarooph
2016-8-4
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!