- Print Statements: Add print statements to verify that the functions are being called as expected.
- Breakpoint: Set breakpoints in the MATLAB editor to inspect the state of the app object and its properties.
access data in App-Designer in nested function call
조회 수: 1 (최근 30일)
이전 댓글 표시
I have defined a variable cr as a public propertie and can refer to it within the program by usind app.cr. However I call a function withinh function
where I need to use the variable, but by running the programm I get an error message:
Unrecognized field name "cr".
app.TMG_solver( n, x, y, z, vx, vy, vz, bx, by, bz);
app.EarthOrbit;
app.OrbitMain;
What am I doing wrong.
댓글 수: 0
답변 (1개)
Aditya
2024년 6월 28일
편집: Aditya
2024년 6월 28일
Hi Claus,
It looks like you're encountering an issue with accessing the cr property within a nested function call in MATLAB App Designer. In MATLAB, nested functions do not automatically have access to the properties of the app unless explicitly passed.
Based on the error that you have provided, your file structure should look like this for it to work properly:
properties (Access = public)
cr
end
methods (Access = private)
function ComputeButtonPushed(app, event)
app.OrbitMain();
end
function OrbitMain(app)
app.EarthOrbit();
end
function EarthOrbit(app)
% Access the cr property
disp(app.cr);
% Call another function without passing app explicitly
app.TMG_solver(n, x, y, z, vx, vy, vz, bx, by, bz);
end
function TMG_solver(app, n, x, y, z, vx, vy, vz, bx, by, bz)
% Access the cr property
disp(app.cr);
end
end
Additional Suggestions
1) Clarify the Scope of cr: Ensure that 'cr; is defined as a public property so it can be accessed throughout the app.
2) Debugging Steps:
If you are having the same file structure and still facing the issue, could you please provide more details to reproduce the issue? You can share the functions that are being used within the file which are leading to this error.
I hope this helps!
참고 항목
카테고리
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!