user3313281
user3313281

Reputation: 5

Change filename in Matlab based on parameter

I want to run my codes for different people. I dedicated a number to each person to save the results.

How can I change the filenames by changing one parameter, to avoid changing the filename in several places. The code is here:

patient_num = 2;
ImagesOutputPath = fullfile([MyFilesPath,'\ImagesOutput_P_2']);
save segmented_img_P_2.mat Segmented_img
save volume_P_2.mat volume
save time_P_2.mat tEnd

Upvotes: 0

Views: 32

Answers (1)

rozsasarpi
rozsasarpi

Reputation: 1641

Do you need something like this?:

patient_num = 2;
ImagesOutputPath = fullfile([MyFilesPath,'\ImagesOutput_P_', num2str(patient_num)]);
save(['segmented_img_P_',  num2str(patient_num), '.mat'], 'Segmented_img')

Upvotes: 2

Related Questions