MATLAB FINANCIAL DERIVATIVES TOOLBOX Instrukcja Użytkownika Strona 95

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 119
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 94
94
Seventh Section
7. Entering and Saving Data Files
Matlab can be used to both load a file of data from an external source and to
save to your PC data-sets that are located in the workspace or that are
created from a function. When you have to deal with small amount of data,
then you can enter them by hand either in the command window or in the
Editor/Debugger. But when you have to work with a large amount of data
retrieved by an external source (e.g. you need to process the historical daily
prices for S&P 500 from 1985 to 1999, saved in a file that was downloaded
from the Internet), then it is an imperative need to use some build-in
functions that can read files of data. Although there are different commands
that can load in workspace various types of data files, we review the two
most important ones.
7.1. Reading Text ASCII Files: The load
command
l
l
o
o
a
a
d
d
is extremely useful command for retrieving from an external source a
text file in ASCII form. The general calling syntax of this command is:
“Data=
l
l
o
o
a
a
d
d
('filename');
The filename is better to either have the extension *.txt or *.dat because if it
does not have any extension, then the
l
l
o
o
a
a
d
d
has a different interpretation (see
h
h
e
e
l
l
p
p
l
l
o
o
a
a
d
d for further details). If the file you want to retrieve is in a different
location than the one that the Matlab’s current directory looks, then a
complete path name should accompanied this command, for example:
“Data =
l
l
o
o
a
a
d
d
(' c:\Documents\Functions\data.txt')”
If the
l
l
o
o
a
a
d
d
command is entered properly, then the contents of the ASCII file
will be stored in a matrix with the dimensionality of the data saved in the
ASCII file. In their simplest form, ASCII files contain rows and columns of
data separated by either a tab or a space. To be accessible by
l
l
o
o
a
a
d
d
the file
should not contain any text or missing values and all columns and rows
Przeglądanie stron 94
1 2 ... 90 91 92 93 94 95 96 97 98 99 100 ... 118 119

Komentarze do niniejszej Instrukcji

Brak uwag