Illustration of advanced file input and output, MATLAB in Mathematics

Illustration of Advanced file input and output:

For illustration, to refer to the third number in the first element of the cell array:

>> subjdata{1}(3)

ans =



The script which reads in this data and echo-prints it is shown here:

1007_Illustration of Advanced file input and output.png

Executing this script generates the following results which are as shown below:

>> textscanex

5.3 a

2.2 b

3.3 a

4.4 a

1.1 b

File close successful

To conclude, we know four techniques of reading from a file. The function load will only work when the values in the file are all of similar type and there is similar number on every line in the file, so that they can be read into the matrix. If this is not the situation, lower level functions should be used. To use these, the file should be opened first and then closed whenever the reading has been done. The fscanf function will read into the matrix, converting the characters to their ASCII equivalents. The textscan function will rather read into a cell array which stores each column from the file into individual column vectors of the cell array. At last, the fgetl function can be used in a loop to read each line from the file as an individual string; the string manipulating functions should then be used to break the string into pieces and convert to numbers.

Posted Date: 10/20/2012 6:29:01 AM | Location : United States

Related Discussions:- Illustration of advanced file input and output, Assignment Help, Ask Question on Illustration of advanced file input and output, Get Answer, Expert's Help, Illustration of advanced file input and output Discussions

Write discussion on Illustration of advanced file input and output
Your posts are moderated
Related Questions
Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Function fopen - file function: The permission string in the call to the fopen function identifies that the file is opened for writing to it. Just as when reading from a file,

Function xlsread - file function: The function xlsread will read from the spreadsheet file. For illustration, to read from file just generated: >> ssnums = xlsread('ranexc

Sorting The Sorting is a process of putting a list in order; either in descending (maximum to minimum), or ascending (minimum to maximum) order. For illustration, here is a li

strvcat function - concatenation: The function strvcat will concatenate it vertically, that means that it will generate a column vector of the strings.   >> strvcat(fir

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

Built-in function for Differentiation: The MATLAB has a built-in function, diff that returns the differences between consecutive elements in a vector. For illustration, >>

Applications of Customized Strings: Labels, Prompts, Arguments to Functions: The one of very useful application of this is to involve numbers in strings that are used to plot

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

This project requires you to use the ideas of Chapter 25 regarding maximization of a function. Here we assume that evolution has acted to generate highly efficient foragers. By hig