How can I solve the eror " Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier. " for this code ?
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!