Cun Zhang’s Blog

June 9, 2008

save plot into tex format in Octave

Filed under: Math, latex — Tags: , , — Cun Zhang @ 17:17

The print command in Octave is so useful! It can save plot into so many format, especially tex which can be used into these articles which are written by tex.

Another use for me is to make  program(mfile,which plot so many plots)  automatization become true.

e.g.

for i=0:2

x=[i:0.01:i+2]*pi;

plot(x,sin(x));

file=[num2str(i) '.jpg'];

print(file, ‘-djpeg’ );

end

close

Save these code into a mfile(e.g, a.m) ,then at the console,run the command:

octave a.m

Another way is to run a.m in Octave console.

Is it amazing? If it be useful for you, please tell me :)

data save/load in Octave(From Octave’s Manual)

Filed under: Uncategorized — Tags: , , — Cun Zhang @ 16:58

 The save and load commands allow data to be written to and read from disk files in various formats. The default format of files written by the save command can be controlled using the functions default_save_options and save_precision.

As an example the following code creates a 3-by-3 matrix and saves it to the file `myfile.mat‘.

     A = [ 1:3; 4:6; 7:9 ];
     save myfile.mat A

Once one or more variables have been saved to a file, they can be read into memory using the load command.

     load myfile.mat
     A
          -| A =
          -|
          -|    1   2   3
          -|    4   5   6
          -|    7   8   9

— Command: save options file v1 v2

Save the named variables v1, v2, , in the file file. The special filename `-‘ can be used to write the output to your terminal. If no variable names are listed, Octave saves all the variables in the current scope. Valid options for the save command are listed in the following table. Options that modify the output format override the format specified by default_save_options.

If save is invoked using the functional form

          save ("-option1", ..., "file", "v1", ...)

then the options, file, and variable name arguments (v1, ) must be specified as character strings.

-ascii
Save a single matrix in a text file.
-binary
Save the data in Octave’s binary data format.
-float-binary
Save the data in Octave’s binary data format but only using single precision. You should use this format only if you know that all the values to be saved can be represented in single precision.
-V7
-v7
-7
-mat7-binary
Save the data in Matlab’s v7 binary data format.
-V6
-v6
-6
-mat
-mat-binary
Save the data in Matlab’s v6 binary data format.
-V4
-v4
-4
-mat4-binary
Save the data in the binary format written by Matlab version 4.
-hdf5
Save the data in HDF5 format. (HDF5 is a free, portable binary format developed by the National Center for Supercomputing Applications at the University of Illinois.)
-float-hdf5
Save the data in HDF5 format but only using single precision. You should use this format only if you know that all the values to be saved can be represented in single precision.
-zip
-z
Use the gzip algorithm to compress the file. This works equally on files that are compressed with gzip outside of octave, and gzip can equally be used to convert the files for backward compatibility.

The list of variables to save may include wildcard patterns containing the following special characters:

?
Match any single character.
*
Match zero or more characters.
[ list ]
Match the list of characters specified by list. If the first character is ! or ^, match all characters except those specified by list. For example, the pattern `[a-zA-Z]‘ will match all lower and upper case alphabetic characters.
-text
Save the data in Octave’s text data format.

Except when using the Matlab binary data file format, saving global variables also saves the global status of the variable, so that if it is restored at a later time using `load‘, it will be restored as a global variable.

The command

          save -binary data a b*

saves the variable `a‘ and all variables beginning with `b‘ to the file data in Octave’s binary format.

— Command: load options file v1 v2
Load the named variables v1, v2, , from the file file. As with save, you may specify a list of variables and load will only extract those variables with names that match. For example, to restore the variables saved in the file data, use the command

          load data

If load is invoked using the functional form

          load ("-option1", ..., "file", "v1", ...)

then the options, file, and variable name arguments (v1, ) must be specified as character strings.

If a variable that is not marked as global is loaded from a file when a global symbol with the same name already exists, it is loaded in the global symbol table. Also, if a variable is marked as global in a file and a local symbol exists, the local symbol is moved to the global symbol table and given the value from the file. Since it seems that both of these cases are likely to be the result of some sort of error, they will generate warnings.

If invoked with a single output argument, Octave returns data instead of inserting variables in the symbol table. If the data file contains only numbers (TAB- or space-delimited columns), a matrix of values is returned. Otherwise, load returns a structure with members corresponding to the names of the variables in the file.

The load command can read data stored in Octave’s text and binary formats, and Matlab’s binary format. It will automatically detect the type of file and do conversion from different floating point formats (currently only IEEE big and little endian, though other formats may added in the future).

Valid options for load are listed in the following table.

-force
The `-force‘ option is accepted but ignored for backward compatibility. Octave now overwrites variables currently in memory with the same name as those found in the file.
-ascii
Force Octave to assume the file contains columns of numbers in text format without any header or other information. Data in the file will be loaded as a single numeric matrix with the name of the variable derived from the name of the file.
-binary
Force Octave to assume the file is in Octave’s binary format.
-mat
-mat-binary
-6
-v6
-7
-v7
Force Octave to assume the file is in Matlab’s version 6 or 7 binary format.
-V4
-v4
-4
-mat4-binary
Force Octave to assume the file is in the binary format written by Matlab version 4.
-hdf5
Force Octave to assume the file is in HDF5 format. (HDF5 is a free, portable binary format developed by the National Center for Supercomputing Applications at the University of Illinois.) Note that Octave can read HDF5 files not created by itself, but may skip some datasets in formats that it cannot support.
-import
The `-import‘ is accepted but ignored for backward compatibility. Octave can now support multi-dimensional HDF data and automatically modifies variable names if they are invalid Octave identifiers.
-text
Force Octave to assume the file is in Octave’s text format.

 From: Octave’s Manual

June 3, 2008

Debian Nvidia driver installation with kernel 2.6.25(Xen)

Filed under: Linux — Tags: , , , — Cun Zhang @ 17:17

Now I use Debian Sid with kernel 2.6.25 which xen support is built in. For this reason the nvidia driver can’t be installed.

1. download nvidia driver

I use Nvidia Geforce MX 4000, so I should download NVIDIA-Linux-x86-96.43.05-pkg1.run driver

2. patch a diff file for kernel 2.6.25

download NVIDIA_kernel-96.43.05-2290218.diff.txt

Then run

# sh /path/to/NVIDIA-Linux-x86-96.43.05-pkg1.run –apply-patch NVIDIA_kernel-96.43.05-2290218.diff.txt

#export IGNORE_XEN_PRESENCE=1
# sh NVIDIA-Linux-x86-96.43.05-pkg1-custom.run

Now the nvidia graphics driver is installed successfully.

Here are two good article about this subject.

1. http://www.nvnews.net/vbulletin/showthread.php?t=110088

2. http://blog.creonfx.com/linux/how-to-install-nvidia-driver-on-2625-2-debian-kernel-with-xen

Powered by WordPress