Saving data array in Matlab data file (.mat) in App Designer

조회 수: 29 (최근 30일)
Mirza Ahmed
Mirza Ahmed 2021년 9월 20일
답변: Walter Roberson 2021년 9월 20일
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!

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile 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!

Translated by