Dear all,
I am working on one big data science project. I need to extract data from one text file into separate columns of Matlab variable. I have attached smaller portion of the data along with this message. Can anybody please tell me where am I going wrong in my code for extracting data from text file? Thank you in advance, My MATLAB code is as follows:
fid = fopen('Nikhil.txt','r');iread=0; icount = 0;while(iread~=1) icount=icount+1; tline=fgetl(fid);corr1=strfind(tline,'Date;Time;Global_active_power;Global_reactive_power;Voltage;Global_intensity;Sub_metering_1;Sub_metering_2;Sub_metering_3'); if(corr1~=0) sizeA= [9 Inf]; [strdat, count]=fscanf(fid,['%D %D %g %g %g %g %g %g %g'],sizeA); iread=iread+1; end;end; %strdat=strdat';
fclose(fid); n=length(strdat); strdat
Best Answer