I'm trying to open .txt files caesar1, caesar2, and caesar3 in a for loop.
for k = 1:3 N = string([1,2,3]); caesarN = strcat('caesar',N); caesarT = strcat(caesarN, '.txt'); caesar(k) = dlmread(caesarT);end
I do end up getting a string array caesarT = [caesar1.txt, caesar2.txt, and caesar3.txt] but dlmread won't open them for some reason (says that Filename must be a character vector). I tried to char(caesarT), but it still doesn't work. What am I missing here? Do I just need to somehow add the characters ' ' to my caesar# strings? (e.g. literally have the string be 'caesar1.txt'… instead of caesar.txt)
Best Answer