Quantzone

Matlab Finance Code

Pages: Prev 1 2 Next

SCOPE: interactively tabulate SEER excel variables

This program asks the user for the SEER variable stored in excel, it tabultes the elements, then write it back to the excel. This facilates creation of excel tables for reporting and publication purposes. Otherwise, manually copying the tabulated results will be very tedious.

text2struc_MSBrucker.m

text2struct_MS is used to open and read data that have been obtained using MS hyphenated technique (LC/MS; GC/MS; CE/MS)and exported as a text file. This function has been design for Brucker software but may be applicable to other software with minimal modifications text2struc_MSBrucker will ask you the location of the text file, a name and the location of a destination folder. text2struc_MSBrucker will create and save 3 files, defaultName.mat, defaultName.dat and defaultName.tra. defaultName.dat will contain the raw data in binary format, defaultName.tra will contain traces (chromatogram, MS spectra or other) that have been created and defaultName.mat a structure (structOut) that contain key information as well as an indexing of the two other files allowing you to rapidly extract key informations.

matlab2tikz

struct2csv

STRUCT2CSV(s,fn)

Output a structure of matrices and cell arrays to a comma delimited file with field names as column headers. A simple method for exporting data structures.

s : any structure composed of one or more matrices and/or cell arrays
fn : file name

Written by James Slegers, james.slegers_at_gmail.com

Covered by the BSD License

Load ASCII

This function loads data from a tab delimited or csv ascii file similar to dlmread/importdata. If the file has fixed width columns and an offset is desired, it uses this information to quickly scan to desired area (making it significantly faster in those scenarios). Useful when working with very large ascii files that cannot be entirely loaded into memory at one time. If a file is loaded in with no offset, load_ascii is comparable to dlmread (faster/slower depends on delimiter). Importdata is many times slower than both.

Example usage: Consider scenario where we have a very large ascii file (fixed width tab delimited, 24 header lines). We are only interested in a section of 2e6 lines, 20e6 past the end of the header. %syntax
%[data,headerText] = load_ascii(filename,delimiter,header,nlines,offset)
tic;data = load_ascii(filename,’\t’,24,2e6,20e6);toc; tic;data2 = dlmread(filename,’\t’,[20e6+24 0 12e6+23 2]);toc; Elapsed time is 3.838641 seconds. Elapsed time is 21.537717 seconds.

Calculate Excel Range

xlrange = xlcalcrange(h,refCell,r,c,m,n)returns the full target range, xlrange in Excel A1 notation to cover an m-by-n array, starting from an offset of r rows & c columns from the starting cell, refCell.

Any workbook\worksheet prefix is removed from refcell, as are any absolute ‘$’ markers prior to range calculation. i.e. refcell = ‘C:\directorypath\[filename.xlsm]worksheet1′!$P$6:$AC$91

becomes:

refcell = P6:AC91

refcell can also be an Excel named range, but requires the Excel workbook to be open via an actxserver COM object, and a handle to the object, h, passed as a function argument. h is ignored if refcell is not a named range.

Note: this file makes use of 2 functions: dec2base27.m & base27dec.m that were sourced from inside of Mathwork’s function, xlswrite.m

Please let me know of any bugs

csvreader

Overview: ————

csvreader is a robust comma separated value (CSV) function for MATLAB. The built-in CSV reading in MATLAB is either for numeric data only (csvread) or does not handle complex strings (dataset). There is no built-in MATLAB function that handles reading CSV files that contain quoted strings that may contain commas. For example, the following CSV will be problematic for MATLAB to read in correctly:

Joe Demo,”2 Demo Street, Demoville, Australia. 2615″,joe@someaddress.com    Jim Sample,”3 Sample Street, Sampleville, Australia. 2615″,jim@sample.com    Jack Example,”1 Example Street, Exampleville, Australia. 2615″,jack@example.com

The second entry of each line is an address that contains a comma. Non-robust CSV parsers will fail to put the entire address in the same cell. Further, csvreader will accept quoted strings that contain line breaks.

For help and example usage, type “help csvreader” from the MATLAB command window.

Installation: ————

The csvreader function uses a Java Archive (JAR) library from the opencsv project. In order to be called from within MATLAB, the opencsv JAR must be placed on MATLAB’s Java class path. For more information on the MATLAB java class path see http://www.mathworks.com/help/matlab/matlab_external/bringing-java-classes-and-methods-into-matlab-workspace.html

To install the JAR follow the following steps:

1. Open MATLAB and change the working directory to the same folder as the opencsv 2.3.jar and installCSVReader.m 2. Run the install script by typing ‘installCSVReader’ in the MATLAB command window

Developers: ———— If you would like to contribute to the development of this function, you can fork this project from my BitBucket repository: https://bitbucket.org/kkusano/csvreader

Save or load the individual properties of an object

Instead of saving or loading an object as a whole, we may need to save or load its properties individually. The demoClass.m is a class definition showing how to do that. Play around it by creating an object, then changing, saving and loading its properties

Getting your data from Matlab into either an Excel Spreadsheet or a Word Table

A simple and quick way of manually getting your data from Matlab into either an Excel Spreadsheet or a Word Table. This can be done by the time it takes to find the range needed for xlswrite. The clipboard is used instead of a COM interface.

Perfect for quickly getting data into a Word or Excel report. A single paste can populate an entire nxm table in Word with a nxm data set.

Three Easy Directions: Generate data set A from your own code. Type toTable(A). Paste into Excel Spreadsheet or Word Table.

Exports figures nicely to a number of vector & bitmap formats.

This function saves a figure or single axes to one or more vector and/or bitmap file formats, and/or outputs a rasterized version to the workspace, with the following properties:

- Figure/axes reproduced as it appears on screen

- Cropped borders (optional)

- Embedded fonts (pdf only)

- Improved line and grid line styles

- Anti-aliased graphics (bitmap formats)

- Render images at native resolution (optional for bitmap formats)

- Transparent background supported (pdf, eps, png)

- Semi-transparent patch objects supported (png only)

- RGB, CMYK or grayscale output (CMYK only with pdf, eps, tiff)

- Variable image compression, including lossless (pdf, eps, jpg)

- Optionally append to file (pdf, tiff)

- Vector formats: pdf, eps

- Bitmap formats: png, tiff, jpg, bmp, export to workspace

This function is especially suited to exporting figures for use in publications and presentations, because of the high quality and portability of media produced.

Pages: Prev 1 2 Next
keep looking »
  • About

    Matlab Finance Code Collector

  • Tag Cloud

  • Recent Comments

  • Meta