Run script file from App designer
이전 댓글 표시
I succeed in run my script file from the app designer but the problem is, it runs in command window and when I ask to show result it shows the old one on the workspace
댓글 수: 13
Rik
2022년 5월 10일
Why are you using a script for anything serious? You should be using functions instead, as those provide a stable interface.
Ayman Shaban
2022년 5월 10일
Rik
2022년 5월 10일
You can absolutely call a function from within a function. So you don't need to use a script at any point.
Ayman Shaban
2022년 5월 11일
cr
2022년 5월 12일
In the function where you are computing the result, copy it to main workspace using eval(). e.g. if result is a scalar, eval(['result=' num2str(result)]). This would make the variable available in main workspace. Another way is to use global variables.
Note that both these are less efficient ways of dealing with variable scopes.
Rik
2022년 5월 12일
How are you calling your function? It sounds like you should set that variable as the output argument of your function.
You should not need eval or global. There are almost always better ways.
Ayman Shaban
2022년 5월 12일
Ayman Shaban
2022년 5월 12일
Rik
2022년 5월 12일
You should edit your function so you can actually retrieve the output and call it like this:
% Button pushed function: ResultButton
function ResultButtonPushed(app, event)
Result = TestPenchCode3; %calling function
app.EditField.Value = Result;
end
You never need to use eval.
Ayman Shaban
2022년 5월 12일
Ayman Shaban
2022년 5월 12일
Rik
2022년 5월 13일
I'm afraid I can't help you with that. The answer will depend on your exact method and data. You could try opening a new question.
Ayman Shaban
2022년 5월 13일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Code Execution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!