| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 646 人关注过本帖
标题:奇怪?
只看楼主 加入收藏
wxx
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-6-2
收藏
 问题点数:0 回复次数:0 
奇怪?

大家帮帮忙:
我做了一个GUI界面,界面上有两组编辑框,每组编辑框里的数值之和为1,如果不为1则进行归一化,归一化操作是由一个按钮来实现的。当归一化完后让归一化的结果还显示在原来的编辑框中,这一步可以实现,但是在运行后来的算法中还会出现一个错误提示“没有归一化”。不知是何原因??????我的部分程序如下:

function run_Callback(hObject, eventdata, handles)

number_sel_index = get(handles.number, 'Value');
data = getappdata(gcbf, 'metricdata');
axes(handles.axes1);
cla;
if (data.a1+data.b1+data.ab1~=1|data.a2+data.b2+data.ab2~=1)&&number_sel_index==1
errordlg('没有归一化','Error');

elseif (data.a1+data.b1+data.ab1==1&&data.a2+data.b2+data.ab2==1)&&number_sel_index==1
A(1)=(data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1)./[1-(data.a1*data.b2+data.b1*data.a2)];
B(1)=(data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1)./[1-(data.a1*data.b2+data.b1*data.a2)];
AB(1)=(data.ab1*data.ab2)./[1-(data.a1*data.b2+data.b1*data.a2)];
X(1)=0;
A(2)=(data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1);
B(2)=(data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1);
AB(2)=(data.ab1*data.ab2);
X(2)=data.a1*data.b2+data.b1*data.a2;
A(3)=data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1;
B(3)=data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1;
AB(3)=data.ab1*data.ab2+data.a1*data.b2+data.b1*data.a2;
X(3)=0;
Y=[A(1) B(1) AB(1) X(1);A(2) B(2) AB(2) X(2); A(3) B(3) AB(3) X(3)];
bar(Y);
legend('A','B','AB','W');
grid on;
elseif (data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1~=1|data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2~=1)&&number_sel_index==2
errordlg('没有归一化','Error');
elseif (data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1==1|data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2==1)&&number_sel_index==2
A(1)=(data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1+data.a1*data.ac2+data.a2*data.ac1+data.a1*data.abc2+data.a2*data.abc1)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
B(1)=(data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1+data.b1*data.bc2+data.b2*data.bc1+data.b1*data.abc2+data.b2*data.abc1)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
C(1)=(data.c1*data.c2+data.c1*data.ac2+data.c2*data.ac1+data.c1*data.bc2+data.c2*data.bc1+data.c1*data.abc2+data.c2*data.abc1)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
AB(1)=(data.ab1*data.ab2+data.ab1*data.abc2+data.abc1*data.ab2)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
BC(1)=(data.bc1*data.bc2+data.bc1*data.abc2+data.abc1*data.bc2)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
AC(1)=(data.ac1*data.ac2+data.ac1*data.abc2+data.abc1*data.ac2)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
ABC(1)=(data.abc1*data.abc2)/[1-(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2)];
X(1)=0;
A(2)=(data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1+data.a1*data.ac2+data.a2*data.ac1+data.a1*data.abc2+data.a2*data.abc1);
B(2)=(data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1+data.b1*data.bc2+data.b2*data.bc1+data.b1*data.abc2+data.b2*data.abc1);
C(2)=(data.c1*data.c2+data.c1*data.ac2+data.c2*data.ac1+data.c1*data.bc2+data.c2*data.bc1+data.c1*data.abc2+data.c2*data.abc1);
AB(2)=(data.ab1*data.ab2+data.ab1*data.abc2+data.abc1*data.ab2);
BC(2)=(data.bc1*data.bc2+data.bc1*data.abc2+data.abc1*data.bc2);
AC(2)=(data.ac1*data.ac2+data.ac1*data.abc2+data.abc1*data.ac2);
ABC(2)=(data.abc1*data.abc2);
X(2)=(data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2);
A(3)=(data.a1*data.a2+data.a1*data.ab2+data.a2*data.ab1+data.a1*data.ac2+data.a2*data.ac1+data.a1*data.abc2+data.a2*data.abc1);
B(3)=(data.b1*data.b2+data.b1*data.ab2+data.b2*data.ab1+data.b1*data.bc2+data.b2*data.bc1+data.b1*data.abc2+data.b2*data.abc1);
C(3)=(data.c1*data.c2+data.c1*data.ac2+data.c2*data.ac1+data.c1*data.bc2+data.c2*data.bc1+data.c1*data.abc2+data.c2*data.abc1);
AB(3)=(data.ab1*data.ab2+data.ab1*data.abc2+data.abc1*data.ab2);
BC(3)=(data.bc1*data.bc2+data.bc1*data.abc2+data.abc1*data.bc2);
AC(3)=(data.ac1*data.ac2+data.ac1*data.abc2+data.abc1*data.ac2);
ABC(3)=data.abc1*data.abc2+data.a1*data.b2+data.b1*data.a2+data.a1*data.c2+data.c1*data.a2+data.c1*data.b2+data.b1*data.c2;
X(3)=0;
Y=[A(1) B(1) C(1) AB(1) BC(1) AC(1) ABC(1) X(1);A(2) B(2) C(2) AB(2) BC(2) AC(2) ABC(2) X(2);A(3) B(3) C(3) AB(3) BC(3) AC(3) ABC(3) X(3)];
bar(Y)
legend('A','B','C','AB','BC','AC','ABC','W');
grid on;
end


function normalization_Callback(hObject, eventdata, handles)

number_sel_index = get(handles.number, 'Value');
data = getappdata(gcbf, 'metricdata');
if number_sel_index==1
a11=data.a1./(data.a1+data.b1+data.ab1);
set(handles.a1, 'String', a11);
b11=data.b1./(data.a1+data.b1+data.ab1);
set(handles.b1, 'String', b11);
ab11=data.ab1./(data.a1+data.b1+data.ab1);
set(handles.ab1, 'String',ab11);
a22=data.a2./(data.a2+data.b2+data.ab2);
set(handles.a2, 'String', a22);
b22=data.b2./(data.a2+data.b2+data.ab2);
set(handles.b2, 'String', b22);
ab22=data.ab2./(data.a2+data.b2+data.ab2);
set(handles.ab2, 'String', ab22);

elseif number_sel_index==2
a11=data.a1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.a1, 'String', a11);
b11=data.b1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.b1, 'String', b11);
c11=data.c1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.c1, 'String', c11);
ab11=data.ab1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.ab1, 'String', ab11);
bc11=data.bc1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.bc1, 'String', bc11);
ac11=data.ac1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.ac1, 'String', ac11);
abc11=data.abc1./(data.a1+data.b1+data.c1+data.ab1+data.bc1+data.ac1+data.abc1);
set(handles.abc1, 'String', abc11);
a22=data.a2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.a2, 'String', a22);
b22=data.b2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.b2, 'String', b22);
c22=data.c2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.c2, 'String', c22);
ab22=data.ab2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.ab2, 'String',ab22);
bc22=data.bc2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.bc2, 'String', bc22);
ac22=data.ac2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.ac2, 'String', ac22);
abc22=data.abc2./(data.a2+data.b2+data.c2+data.ab2+data.bc2+data.ac2+data.abc2);
set(handles.abc2, 'String', abc22);
end


希望高手赐教!!!

2006-07-05 16:56
快速回复:奇怪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023668 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved