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
ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7-6 6-8 7-8 THE COMMPANY LOSES 2,000 FOR EVERY WEEK THE PROJECT LASTS BEYOND 30 WEEKS. fOR EACH OF THE PROPOSALS; ACTIVI

the basic equation of modeling radioactive decay is where the amount of the radioactive substance is at time and is the decay rate. Some radioactive substances decay into other rad

The purpose of this assignment is to use Matlab/Simulink to analyse and simulate a mathematical model of an electromechanical system. This system comprises two component subsystems

-The program should run always until the user enters -1 to exit from the program. - In the main, you should ask user to input any angles in degrees (Ad) and an integer number (N).

Temperature readings were done every hour (starting at 1 P.M., but the end time could vary) and stored in a vector called readings. Write a function called halffit that receives th

what equation equals 36

Rules for variable names: In addition, the variable names must always be mnemonic that means they should make some sense. For illustration, if the variable is storing the radi

I have an assignment to do by MATLAB : the assignment is to design Script that makes (Panorama Stitching) for multiple pictures .. for more information see the link : tobw.net/inde

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

ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7-6 6-8 7-8 THE COMMPANY LOSES 2,000 FOR EVERY WEEK THE PROJECT LASTS BEYOND 30 WEEKS. fOR EACH OF THE PROPOSALS; ACTIVI