MATLAB: Read text file into matlab text file https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data How can we read that kind of data set into matlab? I want just the numerical values. May be to a 4×200 matrix Best Answer Use textscan.FID = fopen('iris.txt')C_data0 = textscan(FID,'%f %f %f %f %s', 200, 'Delimiter',',')numericVector = cell2mat(C_data0(:,1:4)) %ignores the last column of strings Related SolutionsMATLAB: Issue with data format when using textscan() The format should be all lower case for duration.%{hh:mm:ss}THowever, the data appears to be delimited as semicolon. You'd have more luck with readtable:opts = detectImportOptions('D:\SI010118.txt')opts = setvartype(opts,1,'datetime')opts = setvaropts(opts,1,'InputFormat','dd.MM.uuuu HH:mm:ss')readtable('D:\SI010118.txt',opts) MATLAB: Textscan syntax disagreement thisfmt = repmat('%f', 1, 40);data = textscan(dataID, thisfmt);When you use '%f', 40, then you instruct textscan to use "%f" 40 times total, which would just get you your first line. Related QuestionI want to delete all the headerlines and delimiters from the data in the below attached text fileTo read a text file using matlabHow to get the names of the attributes
Best Answer