0
votes

I would like to save a workspace with the result as 14-Nov-2019_094655_script name_L10_P50.mat. Data and time I will add as datestr(now, 'dd-mmm-yyyy_HHMMSS', but I don't know how to add a scrip name and variables in the filename. script_name is the name of the script that I run, L10_P50 are values L and P, which are changed in every run of the script. (L10_P50 means L=10 and P=50 in this run). how to implement it?

edit 1:

I would like to increase the resolution. For that I have written :

fileNamefig = [dstr, '_',flname, '_Num',  num2str(loops_num),'_N', num2str(Nfft), '.jpg'];
saveas(fig,['C:\Users\Matlab\results\fig_files\',fileNamefig])
set(fig,'PaperPositionMode','auto')
print(fig, '-djpeg','-r600','fileNamefig')

It dosnt work. HOw to rewrite it?

1
string concatenation. ['hello_', num2str(12), '_world' ] - Ander Biguri

1 Answers

1
votes
% your variables
L = 10;
P = 50;
% date string
dstr = datestr(now, 'dd-mmm-yyyy_HHMMSS');
% file name
flname = mfilename;
% cancatanate all strings together
matname = [dstr, '_',flname, '_L',  num2str(L),'_P', num2str(P), '.mat'];
% save finally
save(matname)

'''