Next: , Previous: , Up: Directory Index   [Contents][Index]


2.11 file-handling

Loadable Function: data = fitsread ( filename )

Load data from a FITS (Flexible Image Transport System) file.

Examples

data = fitsread("results.fits");             # Load all data in "results.fits"
data = fitsread("results.fits[table1]");     # Load only the table "table1" in "results.fits"
Function File: path = mkpath ( dirs, … )

Makes the directory path dirs, including all parent directories. Returns the final directory in path.

Examples

dir0 = tempname(tempdir);
mkpath(dir0, "a", "b", "c");
assert(isdir(fullfile(dir0, "a", "b", "c")));
Function File: cfg = readConfigFile ( file )

Read a .ini style configuration file into a struct.

Arguments

cfg

configuration file contents

file

configuration file

Examples

inifile = strcat(tempname(tempdir), ".ini");
inicfg = struct("sec1", struct("key1", 1.23, "key2", "hi"), "sec2", struct("key3", "there"));
writeConfigFile(inifile, inicfg);
inicfg2 = readConfigFile(inifile);
assert(inicfg.sec1.key1, inicfg2.sec1.key1);
assert(inicfg.sec1.key2, inicfg2.sec1.key2);
assert(inicfg.sec2.key3, inicfg2.sec2.key3);
Function File: writeConfigFile ( file, cfg )

Write a .ini style configuration file from a struct.

Arguments

file

configuration file

cfg

configuration file contents

Examples

inifile = strcat(tempname(tempdir), ".ini");
inicfg = struct("sec1", struct("key1", 1.23, "key2", "hi"), "sec2", struct("key3", "there"))
writeConfigFile(inifile, inicfg);