How can I solve the eror " Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier. " for this code ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function [load_time_stamp, load_value]=get_the_actual_demand_data()
filename = 'dee1.csv'; delimiter = ','; startRow = 2;
formatSpec = '%s%*s%[^\n\r]'; fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-1);
%dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
load_time_stamp = dataArray{:, 1};
fclose(fileID);
formatSpec = '%*s%f%[^\n\r]'; fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-1);
%dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
load_value = dataArray{:, 1};
fclose(fileID);
end
4 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files 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!