Operation on file, MATLAB in Statistics

Operation on file:

We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is read than the other input functions. The fgetl function reads one line of data from a file into the string; string functions can be used then to manipulate the data. As fgetl reads only one line, it generally is placed in a loop which keeps going until the end of the file is reached. The function feof returns the logical true if the end of the file has been reached. The function call feof(fid) would return the logical true when the end of the file has been reached for the file specified by fid, or logical false when not. A common algorithm for reading from a file into strings would be as shown below:

  •  Try to open the file; check to make sure that the file open was successful.
  •  If opened, the loop until end of the file is reached. For each of line in the file,

-  read it into the string

- manipulate the data

  •  Try to close the file; check to make sure that the file close was successful. 

 

Posted Date: 10/20/2012 6:19:53 AM | Location : United States







Related Discussions:- Operation on file, Assignment Help, Ask Question on Operation on file, Get Answer, Expert's Help, Operation on file Discussions

Write discussion on Operation on file
Your posts are moderated
Related Questions
Data structure layers: There are many layers in this variable. For illustration,  cyls is the whole data structure, that is a vector of structs  cyls(1) is a separate

Rectangle - graphics objects: The other core graphics object is the rectangle that can have curvature added to it (!!). Merely calling the function rectangle without any argum

Example of Functions which complete a task: For illustration, the function below just prints the number arguments passed to it in a sentence format: As this function i

Core Objects: The Core Objects in MATLAB are the very fundamental graphics primitives. The description can be found under the MATLAB Help: Under the Contents tab, click the Ha

Illustration of reading from files: For illustration, suppose that there is a data file 'subjexp.dat' that has on each line a number followed by thecharacter code. The type fu

Median The median is defined only for a data set which has been sorted first, that means that the values are in order. The median of a sorted set of data values (n) is defined

Example of Vectorizing: Likewise, for an operation on a matrix, a nested loop would be needed; for illustration, supposing a matrix variable mat: [r c] = size(mat); for

Working of Editor and debugger: Editor/Debugger, or commands can be typed from Command Window. For illustration, the dbstop command below will set a breakpoint in the fifth li

WHILE Loops: The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action w

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti