(3) 用C语言或Matlab实现基于测点信息量进行测点选择,提供源代码,并以下面某系统依赖矩阵进行测试验证。
t0 t1 t2 t3 t4 t5 t6 t7
F0 0 0 0 1 0 0 1 1
F1 0 0 0 1 0 0 0 1
F2 0 0 1 1 0 0 1 1
F3 0 0 0 1 1 1 1 1
F4 0 0 0 0 0 0 1 1
F5 0 1 0 1 0 1 1 1
F6 1 1 1 1 1 1 1 1
F7 0 0 0 0 0 0 0 0
WPD 1 2 2 6 2 3 6 7
原矩阵
t3 t0 t1 t2 t4 t5
F0 1 0 0 0 0 0
F2 1 0 0 1 0 0
F3 1 0 0 0 1 1
F5 1 0 1 0 0 1
F6 1 1 1 1 1 1
F4 0 0 0 0 0 0
WF1 0 4 6 6 6 6
化简后
t2 t0 t1 t4 t5
F2 1 0 0 0 0
F6 1 1 1 1 1
F0 0 0 0 0 0
F3 0 0 0 1 1
F5 0 0 1 0 1
源程序:
#include
#include "PointMeasure.h"
int t[8];
int F0,F1,F2,F3,F4,F5,F6,F7;
void main()
{
int i=0;
printf("\n本系统中有八个测试单元F0-F7\n设定了八个测试点t0-t7,t0-t7只能取0或者1:\n");
printf("输入t0-t7检测结果:\n");
for(i=0;i<8;i++)
{
printf("t%d is:\n",7-i);
scanf("%d",&t[7-i]);
}
printf("\n第一步:检测t7: t7=%d\n",t[7]);
if (t[7]==0)
{
printf("系统无故障,检测结束\n");
}
else if(t[7]==1)
{
printf("故障存在于F0-F6单元中\n\n第二步:检测测试点t6: t6=%d\n",t[6]);
test_t6();
}
else
printf("输入错误\n");
}
//检测t6//
void test_t6()
{
if (t[6]==0)
{
printf("此时故障可能存在于F1\n\n");
printf("需要继续检测t3,t3=%d\n",t[3]);
test_t3();
}
else if (t[6]==1)
{
printf("故障存在于F0以及F2-F6\n\n");
printf("需要继续检测t3,确定最终结果,t3=%d\n",t[3]);
test_tl3();
}
else
{
printf("输入错误");
}
}
/检测t3点///
void test_t3()
{
if (t[3]==1)
{
printf("F1故障\n");
}
}
void test_tl3()
{
if (t[3]==0)
{
printf("F4故障\n");
}
else if(t[3]