You need to convert the variable t
to a string. You were asking to open the file 'path\t.wav'
, which presumably doesn't exist. Since the variable t
is an integer, you can use int2str
to convert it to a string:
myFile = ['path\' int2str(t) '.wav'];
Only strings can be concatenated with other strings. Of course if you have fewer than 10 files, then you'll have another problem...