I keep getting this error "File identifier must be an integer-valued scalar of type double." when using fopen
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adam Forman
am 19 Sep. 2021
Beantwortet: Sulaymon Eshkabilov
am 19 Sep. 2021
I am trying to read in g-code text into matlabe using fopen and this error keeps appearing:
Could someone please help in deciphering this issue?
Here is my code:
clear
close all
clc
% Read in commands from text file
filename = input('Example2.txt');
fileID = fopen(filename,'r');
Dir = fscanf(fileID,'%f');
fclose(fileID);
% Store commands in "cmd" matrix
for i = 5:5:length(Dir)
for j = 1:1:5
cmd((i/5),j) = Dir(i+j-5,1);
end
end
cmd(:,3:4) = cmd(:,3:4) ./ 100;
Here is what the g-code file looks like:
1 1 0295 0000 000
2 1 0295 0000 365
1 4 0495 0000 000
2 4 0495 0000 365
1 4 0265 0000 000
2 4 0265 0000 365
1 4 0000 0000 000
2 4 0000 0000 185
1 3 0135 0000 000
2 3 0135 0000 365
2 Kommentare
Akzeptierte Antwort
Sulaymon Eshkabilov
am 19 Sep. 2021
Err in the code:
filename = 'Example2.txt'; % Corrected ONE. No input() that creates the error
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!