我在Matlab中遇到了gui的麻烦

时间:2016-11-20 19:19:50

标签: matlab matlab-guide

我不会t write very well English, sorry if you can非常了解我。 我做了我的gui,一切都很好。但是,当我插入数字来计算结果。出现错误:错误 matlab.graphics.internal.figfile.FigFile /读取> @(hObject,EVENTDATA)GUIDEHARDYCROSS(' CALCULAR_Callback',hObject,EVENTDATA,guidata(hObject)) 评估UIControl回调时出错。

这是我的代码。

function CALCULAR_Callback(hObject, eventdata, handles)
Q=str2num(get(handles.Q,'string'));
L=str2num(get(handles.L,'sting'));
D=str2num(get(handles.D,'string'));
f=str2num(get(handles.f,'string'));
g=9.81;
Q1=Q(1,1);
D1=D(1,1);
L1=L(1,1);
A1=(pi*D1^2)/4;
Q2=Q(1,2);
D2=D(1,2);
L2=L(1,2);
A2=(pi*D2^2)/4;
Q3=Q(1,3);
D3=D(1,3);
L3=L(1,3);
A3=(pi*D3^2)/4;
Q4=Q(1,4);
D4=D(1,4);
L4=L(1,4);
A4=(pi*D4^2)/4;
Q5=Q(1,5);
D5=D(1,5);
L5=L(1,5);
A5=(pi*D5^2)/4;
Q6=Q(1,6);
D6=D(1,6);
L6=L(1,6);
A6=(pi*D6^2)/4;
Q7=Q(1,7);
D7=D(1,7);
L7=L(1,7);
A7=(pi*D7^2)/4;
Q8=Q(1,8);
D8=D(1,8);
L8=L(1,9);
A8=(pi*D8^2)/4;
Q9=Q(1,9);
D9=D(1,9);
L9=L(1,9);
A9=(pi*D9^2)/4;
Q10=Q(1,10);
D10=D(1,10);
L10=L(1,10);
A10=(pi*D10^2)/4;
%hf PARA MALLAS

%MALLA 1 
Q1_1=-Q1;
K1_1=(f*L1)/(2*g*D1*A1^2);
hf1_1=-(Q1_1^2)*K1_1;
hf1_Q1_1=abs(hf1_1/Q1_1);
Q2_1=Q2;
K2_1=(f*L2)/(2*g*D2*A2^2);
hf2_1=(Q2_1^2)*K2_1;
hf2_Q2_1=abs(hf2_1/Q2_1);
Q3_1=-Q3;
K3_1=(f*L3)/(2*g*D3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ERRORPORCENTUAL_2F=abs(100*DELTAQ_2F/SUMAQ_2F);
ERRORPORCENTUAL_2=ERRORPORCENTUAL_2F;
DELTAQ_3F=-(hf4_3F+hf7_3F+hf8_3F+hf9_3F+hf10_3F)/(2*(hf4_Q4_3F+hf7_Q7_3F+hf8_Q8_3F+hf9_Q9_3F+hf10_Q10_3F));
DELTAQ_3=DELTAQ_3F;
SUMAQ_3F=(Q4_3F+Q7_3F+Q8_3F+Q9_3F+Q10_3F);
ERRORPORCENTUAL_3F=abs(100*DELTAQ_3F/SUMAQ_3F);
ERRORPORCENTUAL_3=ERRORPORCENTUAL_3F;
end
QFINAL=[abs(Q1_1F) abs(Q2_1F) abs(Q3_1F) abs(Q4_1F) abs(Q5_2F) abs(Q6_2F) abs(Q7_2F) abs(Q8_3F) abs(Q9_3F) abs(Q10_3F)]
set(handles.CAUDALESFINALES,'string',num2str(QFINAL));
set(handles.ERROR1,'string',num2string(ERRORPORCENTUAL_1));
set(handles.ERROR2,'string',num2string(ERRORPORCENTUAL_2));
set(handles.ERROR3,'string',num2string(ERRORPORCENTUAL_3));

0 个答案:

没有答案