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
As shown in Figure 1, Ecosystem carbon (C) cycles in a tropical forest can be modeled using three "compartments":  aboveground (AG), belowground (BG), and soil organic matters (SOM

Example of Referring elements: the vector can also be extended. For illustration, the following generates a vector which has three elements. And then referring to the fourth e

The natural frequencies of a fixed-fixed uniform shaft made of homogeneous material undergoing longitudinal vibration is given by rad/s, where L is the length of the bar, G is th

Goal: Learn how to do statistics, sorting and curve fitting in Matlab. Put all of those ".m" files in a folder called yourname_lab7, and zip the folder and submit it on the class w

i have a problem in doing my project which detects image forgery detection using resampling technique any one please help in writing my program

A three degree of freedom system is shown in Figure.  The three masses are each 1 kg and are constrained to move in the directions shown.   The three stiffnesses are   5 kN/m, 50 k

Illustration to logical function: In addition to such logical operators, the MATLAB also has a function xor, that is the exclusive or function. It returns the logical true if

using 0de 45 how can i get the anlytical and numerical solutions for an equation,,

1. Write a function to threshold your images separating the background from the foreground: Implement the "peakiness" detection algorithm described in class. The output of your