MATLAB: How to convert Fotran format statment in matlab

format specifierfortran -matlab

i want to convert this Fortan statment in matlab?
FORMAT(1001E15.6)

Best Answer

Is the format being used to read data, or to write data?
If it is being used to write data, then the equivalent would be
fmt = repmat('%15.6e', 1, 1001);
It has been a while since I last did any fortran, so I do not recall at the moment if it automatically added newline; you might need to use
fmt = [repmat('%15.6e', 1, 1001), '\n'];
If, on the other hand, it is being used to read data, then there is no direct equivalent. Using '%15.6e' as an input format for fscanf() or sscanf() or textscan() will seldom do what you expect. The easiest way for reading is to use https://www.mathworks.com/help/matlab/ref/matlab.io.text.fixedwidthimportoptions.html