MATLAB: Saving data to indexed variable names file I would like to save data in file with a name that is tagged with the loop index, e.g. filename1, filename2, filename3, etc. The data is a 600 x 13 array. thank you. Best Answer http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3Fhttp://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F Related SolutionsMATLAB: Variable name Best not to do that.http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F MATLAB: Using variable names for saving data http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3Ffor K = 1 : 20 filename = sprintf('data%04d.mat', K); save(filename, 'VariableName');endIf you have more than 9999 iterations then increase the 4 to the maximum number of digits you need. Related QuestionSaving with variable nameSaving problems, desired nameImerode and imopen
Best Answer