Borrar filtros
Borrar filtros

Save workspace output to a file

17 visualizaciones (últimos 30 días)
alpedhuez
alpedhuez el 31 de Mayo de 2018
Comentada: Sarmed Wahab el 3 de Sept. de 2022
I run a program and output various results to a workspace. Is there anyway to put all the outputs in a workspace into a single file?
  1 comentario
Sarmed Wahab
Sarmed Wahab el 3 de Sept. de 2022
I am posting this for people finding relative answer.
for i = 1:5
x = rand(10,1) ;
y = 3*x + i^2 ;
plot(x,y,"bo"); hold on;
a = plot(x,y) ; hold off;
dest_dir = "C:\folder\PROJECT DATA\figure" + i ;
mkdir(dest_dir);
filename = "plot"+string(i)+".png";
% saveas(fig,filename)
fig_file = fullfile(dest_dir , filename)
%saveas(a, filename) %save the file there directory
saveas( a, fig_file)
result = "results"+i;
matfile = fullfile(dest_dir, result);
save(matfile);
%save(result)
end

Iniciar sesión para comentar.

Respuestas (2)

Aakash Deep
Aakash Deep el 31 de Mayo de 2018
Hello Alpedhuez,
You can use the
save
command to save multiple workspace variables in a single file. You can do this as follows,
save filename variable1 variable2 variable_n
this will generate a .mat file into your current directory. You can load it back into your workspace by double-clicking the file or using load command.
Hope this helps.
Regards,
ADC

dpb
dpb el 31 de Mayo de 2018
>> help save
save Save workspace variables to file.
save(FILENAME) stores all variables from the current workspace in a
MATLAB formatted binary file (MAT-file) called FILENAME. Specify
FILENAME as a character vector or a string scalar. For example, specify
FILENAME as 'myFile.mat' or "myFile.mat".
...

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by