How to create an input file ?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
omar ahmed
am 24 Aug. 2022
Beantwortet: omar ahmed
am 9 Okt. 2022
Have certain inputs to my code. And I want to create an input file with this inputs and to be able to use this inputs in my code. And at the same time to be able to change them if I wanted.
2 Kommentare
Geoff Hayes
am 25 Aug. 2022
@omar ahmed - what are the inputs? How many inputs are there? Please provide some details on the input file and the function (or script?) that reads the data.
Mathieu NOE
am 30 Aug. 2022
Akzeptierte Antwort
Weitere Antworten (1)
Pratik Pawar
am 7 Okt. 2022
Please refer to the following code to read integer inputs from a file.
input_file = fopen('input_file_name', 'r'); % read the input file
if(input_file == -1)
error("File can't be read");
end
[number, count] = fscanf(input_file, "%d", 1);
while(count == 1)
fprintf("%d", number); % print the number
[number, count] = fscanf(input_file, "%d", 1); % read the next number
end
If the above information is not helpful, please feel free to add more details on the input file.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!