Saving data array in Matlab data file (.mat) in App Designer
조회 수: 31 (최근 30일)
이전 댓글 표시
Hello dear mates,
I have a set of data array and I am using App Designer. What is the syntax to save the data array in (.mat) file extension? Showing an example can be the best, thank you!
댓글 수: 0
채택된 답변
Walter Roberson
2021년 9월 20일
save('YourFileName.mat', 'NameOfVariable', 'AnotherVariable')
Note that if the values you want to save are currently stored within app or a graphic object, then you need to extract them into a local variable in the name you want them to appear in the .mat . For example,
x_range_start = app.Edit1.Value;
x_range_end = app.Edit2.Value;
save('x_range.mat', 'x_range_start', 'x_range_end');
It is often a good idea to keep track of the directory the user wants to write into, and build the file name instead of using a fixed filename. For example,
results_dir = app.Edit7.Value;
filename = fullfile(results_dir, 'x_range.mat');
x_range_start = app.Edit1.Value;
x_range_end = app.Edit2.Value;
save(filename, 'x_range_start', 'x_range_end')
Notice when you do this, that you do not pass in 'filename' . Use the ' ' when you want to pass in a literal text string; use a variable without surrounding ' ' if you want MATLAB to examine the value of the variable to find the text string.
댓글 수: 0
추가 답변 (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!