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
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 =

Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

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

Writing to Files: There are many lower level functions which can write to files. We will focus on the fprintf function that can be used to write a file and also to append to a

Indexed empty matrix: The Individual elements cannot be eliminated from matrices, as matrices always have the similar number of elements in every row. >> mat = [7 9 8; 4 6

Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

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

Illustration of Labels and prompts: The program below prompts the user for endpoints (x1, y1) and (x2, y2) of a line segment, and computes the midpoint of the line segment, th

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