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

32 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Sept. de 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.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by