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

20 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Sep. 2021
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.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by