How to load variables from a workspace in App Designer?
조회 수: 19 (최근 30일)
이전 댓글 표시
I am trying to make an app which will allow me to load variables from a workspace and then plot these variables or run whatever manipulations on them; I have done several trails, but I failed.
Here you are the very basic trail.
I use button linked to
uiopen('load')
to load a workspace which has a structure called QCM_FH; after loading the file, I have another button to plot two columns from a table in this structure.
plot(QCM_FH(19).File(1).Cell(1).Data.Time, QCM_FH(19).File(1).Cell(1).Data.deltaF_1);
when I click on the plot button, I get this error.
Undefined variable "QCM_FH" or class "QCM_FH".
if I use this form instead
plot(app.QCM_FH(19).File(1).Cell(1).Data.Time, app.QCM_FH(19).File(1).Cell(1).Data.deltaF_1);
I get...
No appropriate method, property, or field 'QCM_FH' for class 'OpenFIle'
I tried other tricks like adding the structure name as property to the app but nothing worked. Any tips?
채택된 답변
Chris Portal
2017년 3월 8일
It sounds like you are trying to share data between 2 different button callbacks - one that does the load, and the other that does the plotting. Here's what's happening...
When you call UIOPEN, the data is getting loaded into the first button's callback workspace. The data is only visible to that callback, and when the callback exits, the data is getting cleared. In order to use the data in another callback, you have to cache the data somewhere that you can access later.
In the GUIDE world, you would normally cache the data in the handles structure or in some component's UserData property. In the App Designer world, the idea is the same, but the recommended place to cache it is in an app variable, exactly as you are doing.
Hope this helps!
추가 답변 (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!