MATLAB: How to save a .mat file and .py file automatically with a ‘variable’s’ value as filename using MATLAB

MATLAB

Eg: If I have a 'gradient'=20 and 'number' = 10. How to save a .mat file and .py file with a filename 20_10.

Best Answer

G = 20;
N = 10;
F = sprintf('%d_%d.mat',G,N);
save(F,...)