I have the following code:
ptol = [2, 4, 8, ...];
a = ptol(1)
fid = fopen( a,\'r\');
I need to open a file determined by which number is call
a
is a number, I guess.
Thus, you need to specify a string which corresponds to the file name.
Does the file have any extension? num2str
and strcat
should do the magic.
The code:
fileName = strcat(num2str(a),'.ext');
fid = fopen(fileName,'r');
Notice that .ext
has to be replace with the actual extension. If you are using .txt
files, then replace with .txt
.
Also, check for the position of the file (you need to specify the exact path).