Writing data to a file, MATLAB Programming

Writing data to a File:

The save function can be used to write a data from the matrix to the data file, or to append a data file. The format is as shown below:

save filename matrixvariablename -ascii

The -ascii qualifier is used when generating a text or data file. The following generates a matrix and then saves the values of the matrix variable to a data file known as the testfile.dat:

>> mymat = rand(2,3)

mymat =

0.4565  0.8214  0.6154

0.0185  0.4447  0.7919

>> save testfile.dat mymat -ascii

This generates a file known as the testfile.dat which stores the numbers

0.4565  0.8214  0.6154

0.0185  0.4447  0.7919

The type command can be used to show the contents of the file; note that the scientific notation is used as shown below:

>> type testfile.dat

4.5646767e-001  8.2140716e-001  6.1543235e-001

1.8503643e-002  4.4470336e-001  7.9193704e-001

Note: When the file already exists, then the save function will overwrite it; save always starts writing from the starting of a file.

Posted Date: 10/18/2012 7:08:35 AM | Location : United States







Related Discussions:- Writing data to a file, Assignment Help, Ask Question on Writing data to a file, Get Answer, Expert's Help, Writing data to a file Discussions

Write discussion on Writing data to a file
Your posts are moderated
Related Questions
MATLAB. • MATLAB Programming; • Simulation in MATLAB.

how to write a program to determine the day of the week. using GUI.

Hello sir, I am Bharat Prajapati.I am working on Copy-move forgery detection using 2D-DWT transform.How to code in matlab to detect copy-move forgery in the given image.Please help

2)''dbcont'' command for debugging is used to Select one: a. Continue normal code execution from the debug prompt. b. List all breakpoints. c. Execute (step) one or more lines

This problem description is taken from Illingworth and Golosnoy [1]: For physical systems of inhomogeneous composition, di usion is often observed to cause a change of phase, even

Variables and Assignment Statements: A variable is used in order to store a value in a MATLAB session, or in a program. The Workspace Window represents variables which have be

Algorithms: Before writing any computer program, it is very useful to first outline the steps which will be essential. An algorithm is the series of steps required to solve a

Implement a single-layer perceptron and train it to translate the digital letters given in the file "pattern1" into the corresponding ASCII representation. Plot a training curve an

The fundamental theorem of calculus states that the de?nite integral of a function may be found from the antiderivative of the function. However, for many functions, it is much eas

Model the three degree of freedom system shown in Figure Q5 and solve for the displacements of the three masses due to a force of 10 N applied to the bottom mass at a frequency of