How to set output in Static text box in MATLAB GUI for a calculation in pushbutton
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am trying to code in MATLAB GUI push button for calculation, that calculation I firstly coded in Script file and is ok, but in GUI pushbutton i am facinng some problem, I would like to show the code that I am using in pushbutton callback only and i do not code in any other callback function
global D1 D2 dh t V1 V2 rowNo LL L
D1=str2num(get(handles.D1,'String'));
D2=str2num(get(handles.D2,'String'));
dh=str2num(get(handles.dh,'String'));
t=str2num(get(handles.t,'String'));
V1=str2num(get(handles.V1,'String'));
V2=str2num(get(handles.V2,'String'));
rowNo=str2num(get(handles.rowNo,'String'));
LL=str2num(get(handles.LL,'String'));
L=str2num(get(handles.L,'String'));
s1=pi*D1^2/4;
s2=pi*D2^2/4;
Sb=pi*dh^2/4;
press=101325;
q=1.293;
c=340;
S=(2*pi*D1/2)*LL;
M10=V1/c;
M11=M10*s1/(rowNo*Sb+s1);
M20=V2/c;
M21=M20*s2/(rowNo*Sb+s2);
Nextspeed=[M11*340;M21*340];
Mb=(M21-M20)*(s2/Sb);
Ub=press/(q*c);
Ubspeed=Mb*c+Ub/Sb;
Hrate=rowNo*Sb/S;
R=(7.337*(1+72.23*Mb)*10^-3)/Hrate;
X=(2.2245*(1+51*t)*(1+204*dh)*10^-5)/Hrate;
Z1=q*c/s1;
Z2=q*c/s2;
Zb=q*c/Sb;
Z=q*c*(R+1*i*X)/Sb;
A=Z^-1 ;
G=zeros(4,4);
H=zeros(4,4);
B1=M11*Z1^-1;
B2=M11*Z1^-1;
B3=M10*Z1;
B4=M10*Z1^-1;
B5=A*(1-(M10-M11)^2*Zb^2*Z1^-2);
C1=M21*Z2;
C2=M21*Z2^-1;
C3=M20*Z2;
C4=M20*Z2^-1;
E1=1-M10^2;
E2=1-M20^2;
G(1,1)=(1-B3*(B4+B5))/E1;
G(1,2)=(B1-B3*(1+B1*(B4+B5-B2)))/E1;
G(1,3)=B3*B5/E1;
G(1,4)=B3*C1*B5/E1;
G(2,1)=B5/E1;
G(2,2)=(1+B1*(B5-B2))/E1;
G(2,3)=-B5/E1;
G(2,4)=-C1*B5/E1;
G(3,1)=C3*B5/E2;
G(3,2)=B1*C3*B5/E2;
G(3,3)=(1-C3*(C4+B5))/E2;
G(3,4)=(C1-C3*(1+C1*(C2+B5-C4)))/E2;
G(4,1)=-B5/E2;
G(4,2)=-B1*B5/E2;
G(4,3)=B5/E2;
G(4,4)=(1+C1*(B5-C2))/E2;
frequency=0:6:6486;
K=2*pi*frequency/340;
a1=K*L*E1^-1;
a2=K*L*E2^-1;
F1=cos(M10*a1)-1*i*sin(M10*a1);
F2=cos(M20*a2)-1*i*sin(M20*a2);
Htotal=zeros(4,4328);
Gtotal=zeros(4,4328);
Htotal=[];
Gtotal=[];
n=1;
for j=1:1:1082
H(1,1)=F1(n)*cos(a1(n));
H(1,2)=1*i*F1(n)*Z1*sin(a1(n));
H(1,3)=0;
H(1,4)=0;
H(2,1)=1*i*F1(n)*Z1^-1*sin(a1(n));
H(2,2)=F1(n)*cos(a1(n));
H(2,3)=0;
H(2,4)=0;
H(3,1)=0;
H(3,2)=0;
H(3,3)=F2(n)*cos(a2(n));
H(3,4)=1*i*F2(n)*Z2*sin(a2(n)^2);
H(4,1)=0;
H(4,2)=0;
H(4,3)=1*i*F2(n)*Z2^-1*sin(a2(n)^2);
H(4,4)=F2(n)*cos(a2(n));
Htotal(:,4*n-3:4*n)=H;
Gtotal(:,4*n-3:4*n)=G;
n=n+1;
end
guidata(hObject, handles);
set(handles.Result,'String',num2str(Htotal));
set(handles.G,'String',num2str(Gtotal));
but output is not same as Script file moreover in a complex matrix form. So please can anybody help me how can I solve this problem? Thanks if I want to create callback so where should I code? is it in opening function?
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!