Illustration of writing variables to a file, MATLAB in Mathematics

Illustration of Writing variables to a file:

For illustration, in the below session in the Command Window, 3 variables are generated; these are then exhibited using who. Then, the variables are saved to file named 'sess1.mat'. The who function is then used to show the variables stored in that file.

>> mymat = rand(3,5)

mymat =

   0.9501   0.4860   0.4565   0.4447   0.9218

   0.2311   0.8913   0.0185   0.6154   0.7382

   0.6068   0.7621   0.8214   0.7919   0.1763

>> x = 1:6;

>> y = x.^2;

>> who

Your variables are:

mymat x y

>> save sess1

>> who -file sess1

Your variables are:

mymat x y

 

To save only one variable to a file, the format is as shown below:

save filename variablename

 

For illustration, only the matrix variable mymat is saved in a file known as sess2

>> save sess2 mymat

>> who -file sess2

Your variables are:

mymat

 

Posted Date: 10/20/2012 6:42:06 AM | Location : United States







Related Discussions:- Illustration of writing variables to a file, Assignment Help, Ask Question on Illustration of writing variables to a file, Get Answer, Expert's Help, Illustration of writing variables to a file Discussions

Write discussion on Illustration of writing variables to a file
Your posts are moderated
Related Questions
If I have a vector representing the packed storage form of a symmetric matrix, how do I perform a cholesky factorisation on that?

Three-dimensional pie and bar: For the bar3 function, x & y vectors are passed and the function displays three-dimensional bars as shown in figure: Figure: Three-dimen

Function isreal - complex numbers: The function isreal returns 1 for logical true when there is no imaginary part of the argument, or 0 for false when the argument does have a

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Logical Vectors: The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each eleme

Use of logical vector: Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg: >> sum(isg) ans =

Creating Customized strings: There are many built-in functions which create customized strings, including blanks, char, and sprintf. We know that the char function can be u

Creating string Variables: The string consists of a few numbers of characters (including, possibly, none). These are the illustrations of the strings: '' 'x' 'ca

User-defined functions: Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal