Unrecognized function or variable in APP DESIGNER
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
when I push Vypocet_Button i my app, it calculates points of great circle on sphere. And I need to use these results, when I push another ProtokolButton (it should generate .txt with results). The problem is that, the app does not have in memory values calculated after pushing first button (Unrecognized function or variable). I tried to use Properties, but with no result...
% Button pushed function: Vypocet_Button
function Vypocet_ButtonPushed(app, event)
Ua_D = app.VychBod_U_stupen.Value;
Ua_M = app.VychBod_U_minuta.Value;
Ua_S = app.VychBod_U_vterina.Value;
Va_D = app.VychBod_V_stupen.Value;
Va_M = app.VychBod_V_minuta.Value;
Va_S = app.VychBod_V_vterina.Value;
Ub_D = app.KoncBod_U_stupen.Value;
Ub_M = app.KoncBod_U_minuta.Value;
Ub_S = app.KoncBod_U_vterina.Value;
Vb_D = app.KoncBod_V_stupen.Value;
Vb_M = app.KoncBod_V_minuta.Value;
Vb_S = app.KoncBod_V_vterina.Value;
R = app.PolomrkoulemEditField.Value;
poc = app.PoetmezilehlchbodEditField.Value;
Ua = deg2rad(Ua_D + Ua_M/60 + Ua_S/3600);
Va = deg2rad(Va_D + Va_M/60 + Va_S/3600);
Ub = deg2rad(Ub_D + Ub_M/60 + Ub_S/3600);
Vb = deg2rad(Vb_D + Vb_M/60 + Vb_S/3600);
% ortodroma
V_orto_int = (Vb-Va)/poc; % pravidelne deleni intevalu vymezeneho zemepisnymi delkami bodu A a B
V_orto = Va:V_orto_int:Vb; % vektor zem.delek boduu ortodromy
l_orto = acos(cos(pi/2-Ua)*cos(pi/2-Ub) + sin(pi/2-Ua)*sin(pi/2-Ub)*cos(Vb-Va)); % delka orodromy
azi_orto = asin((cos(Ub)*sin(Vb-Va)) / (sin(l_orto))); % azimut na prvnim bode
U_orto = Ua;
for i = 1:length(V_orto)-1 %vypocet zem. sirek jednotlivych bodu
alfa(i) = acos(-cos(azi_orto(i))*cos(V_orto_int) + sin(azi_orto(i))*sin(V_orto_int)*cos(pi/2 - U_orto(i)));
azi_orto(i+1) = pi - alfa(i);
U_orto(i+1) = pi/2 - asin((sin(pi/2 - U_orto(i))*sin(azi_orto(i))) / (sin(alfa(i))));
end
U_orto = degrees2dms(rad2deg(U_orto)); % prevod na stupne
V_orto = degrees2dms(rad2deg(V_orto));
end
% Button pushed function: ProtokolButton
function ProtokolButtonPushed(app, event)
hlavicka1 = '---------SOURADNICE BODU ORTODROMY---------';
hlavicka2 = 'c.b. U[D M S] V[D M S]';
cb = 1:poc+1 ;
fileID = fopen('vysledky.txt','w');
fprintf(fileID,'%s\n',hlavicka1);
fprintf(fileID,'%s\n',hlavicka2);
fprintf(fileID,'%2d %8d %4d %7.3f %8d %4d %7.3f\n',[cb; U_orto(:,1)'; U_orto(:,2)'; U_orto(:,3)';V_orto(:,1)'; V_orto(:,2)'; V_orto(:,3)']);
fprintf(fileID,'delka ortodromy = %.3f m\n',l_orto)
fprintf(fileID,'%s\n',' ')
end
end
댓글 수: 2
Cris LaPierre
2021년 11월 4일
What variable can't it find? Please share the complete error message (all the red text)
채택된 답변
Cris LaPierre
2021년 11월 4일
Keep in mind variable scope. Variables created inside a function are destroyed as soon as the function ends. You need to add those variables you want to access in another callback to the apps structure. You do this my listing them as app properties, and then assigning to and accessing them by prepending them with 'app.'. See the 'Share Data Within App Designer Apps' page.
For example
app.l_orto = acos(cos(pi/2-Ua)*cos(pi/2-Ub) + sin(pi/2-Ua)*sin(pi/2-Ub)*cos(Vb-Va)); % delka orodromy
...
fprintf(fileID,'delka ortodromy = %.3f m\n',app.l_orto)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!