function [Time,Displacement,ForceZ] = importfile1(fileName) %IMPORTFILE1 Import numeric data from a text file as column vectors. % [DATE1,TUEJUL082014,VARNAME3] = IMPORTFILE1(FILENAME) Reads data from % text file FILENAME for the default selection. % % [DATE1,TUEJUL082014,VARNAME3] = IMPORTFILE1(FILENAME, STARTROW, ENDROW) % Reads data from rows STARTROW through ENDROW of text file FILENAME. % % Example: % [Date1,TueJul082014,VarName3] = importfile1('RELAXATION.txt',23, % 12107); % % See also TEXTSCAN.
% Auto-generated by MATLAB on 2014/07/17 12:07:48
%% Initialize variables. delimiter = '\t'; if nargin<=2 startRow = 26; endRow = 30742; end
%% Format string for each line of text: % column1: text (%s) % column2: text (%s) % column3: text (%s) % For more information, see the TEXTSCAN documentation. formatSpec = '%s%s%s%[^\n\r]';
%% Open the text file. fileID = fopen(fileName,'r');
%% Read columns of data according to format string. % This call is based on the structure of the file used to generate this % code. If an error occurs for a different file, try regenerating the code % from the Import Tool. dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false); for block=2:length(startRow) frewind(fileID); dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(block)-1, 'ReturnOnError', false); for col=1:length(dataArray) dataArray{col} = [dataArray{col};dataArrayBlock{col}]; end end
%% Close the text file. fclose(fileID);
%% Post processing for unimportable data. % No unimportable data rules were applied during the import, so no post % processing code is included. To generate code which works for % unimportable data, select unimportable cells in a file and regenerate the % script.
%% Allocate imported array to column variable names Time = dataArray{:, 1}; Displacement = dataArray{:, 2}; ForceZ = dataArray{:, 3}; TimeMat=str2double(Time(:,1)); ForceMat=str2double(ForceZ(:,1)); DispMat=str2double(Displacement(:,1));
This is the program ....and the file from which i have to extract the data...... #
What i want to do is 1. i want the program to start reading the data from the line where the readings start.
2. so my idea is is to write a code which checks every line for it's first letter ,as whether a alphabet or number.... if it is a alphabet it should not take the vale and the vise versa.