Illustration of writing variables to a file, MATLAB in Mathematics

Assignment Help:

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

 


Related Discussions:- Illustration of writing variables to a file

Histogram - plot functions, Histogram: The histogram is a particular t...

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Illustration of labels and prompts, Illustration of Labels and prompts: ...

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

User-defined functions - matlab, User-defined functions: Therefore, al...

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

Function xlsread - file function, Function xlsread - file function: Th...

Function xlsread - file function: The function xlsread will read from the spreadsheet file. For illustration, to read from file just generated: >> ssnums = xlsread('ranexc

Naive Gauss Reduction, Write a MATLAB function [d1, u1, l1, c1, r1] = Naive...

Write a MATLAB function [d1, u1, l1, c1, r1] = NaiveGaussArrow(d, u, l, c, r) that takes as input the 5 vectors de ned above representing A. This function performs Naive Gauss redu

Program of built-in factorial function, Program of built-in factorial funct...

Program of built-in factorial function: Calling this function yields similar result as the built-in factorial function: >> fact(5) ans =   120 >> factorial(

Optimal foraging theory, This project requires you to use the ideas of Chap...

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

Variance, The variance is generally defined in terms of the arithmetic me...

The variance is generally defined in terms of the arithmetic mean as: At times, though, the denominator is defined as n instead of n - 1. The default definition used by t

Plot functions, Plot Functions: Faraway, we have plotted to generate t...

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Function fopen - file function, Function fopen - file function: The pe...

Function fopen - file function: The permission string in the call to the fopen function identifies that the file is opened for writing to it. Just as when reading from a file,

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd