Remove all doubles, cell arrays and char arrays from a structure?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am writing a piece of software with a GUIDE interface.
My data is all stored in the handles structure. In hindsight, I should have put every variable the user enters, and every result of calculations in a seperate structure like UserData.XXX rather than handles.XXX but it's a very large interface and I am working to a tight time constraint so can't easily change this now.
When the user opens a new GUI, I clear all of the edit boxes and result outputs whose tag names end in INPUT or OUTPUT. It's fast and works well, but the data remains in the handles structure. When a computation button is pressed again, naturally it still works, as the data is still present even if the GUI is empty.
How can I remove fields from the handles structure if (and only if) they are character arrays, doubles, or cell arrays? That way my GUI UIControl data, panels etc. can remain in the handles structure.
I was hoping to easily use the class and rmfield functions, but I can only get the class function to identify that handles is a struct, rather than return the class of each item contained within it.
Thanks, Matt.
댓글 수: 2
Stephen23
2018년 10월 26일
"In hindsight, I should have put every variable the user enters, and every result of calculations in a seperate structure like UserData.XXX rather than handles.XXX but it's a very large interface and I am working to a tight time constraint so can't easily change this now."
That might be your best option. I would simply replace your handles.XXX with handles.mystuff.XXX, which could be done with a simple text find-and-replace, although you have to check each one so that you do not change the GUIDE fields, which will take a few minutes. After that, you can process/replace/initialize/... the contents of handles.mystuff as you require.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!