Reading from files, MATLAB in Statistics

Reading from Files:

There are many lower level functions which read from files. The function fscanf reads the formatted data into a matrix, by using conversion formats like %s for strings, %d for integers, and %f for floats. The function textscan reads text data from a file and stores it in the cell array. The fgetl and fgets functions both read the strings from a file one line at a time; the dissimilarity is that the fgets holds the newline character when there is one at the end of the line, while the fgetl function gets rid of it. All these functions at first need opening the file, and then closing it when terminated.

As the fgetl and fgets functions read one line at a time, such functions are usually in some form of a loop. The fscanf and textscan functions can read the whole data file into one data structure. In terms of the level, these two functions are somewhat in between the load function & the lower level functions like fgetl. The file should be opened by using fopen first, and must be closed by using fclose afterward the data has been read. Though, no loop is needed; they will read in the whole file automatically but into the data structure.



Posted Date: 10/20/2012 6:18:34 AM | Location : United States

Related Discussions:- Reading from files, Assignment Help, Ask Question on Reading from files, Get Answer, Expert's Help, Reading from files Discussions

Write discussion on Reading from files
Your posts are moderated
Related Questions
Curve Fitting: The data is fundamentally either discrete or continuous. In most of the applications, data is sampled, for illustration, The temperature recorded every ho

Logical errors: The Logical errors are more complicated to locate, as they do not result in any error message. The logical error is a mistake in reasoning by the programmer, b

Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of

Illustration of nested for loops and the if statements: For illustration,when the file contains: 33   -11  2  4      5   9 22     5  -7  2     11    3 the outco

Illustration of Median When the vector is not in sorted order to start with, the median function will still return the right answer (it will sort the vector automatically). For

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

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

#qYou will need to examine two of the nine sections of data: one section of qualitative data (choose either Gender or Position) one section of quantitative data (choose either Intr

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

Editor/Debugger: The MATLAB has numerous useful functions for debugging, and debugging can also be completed through its editor, which is known as the Editor/Debugger. Typi