Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.88 KB File ID: #35404

myDynamicClass

by Mark Mikofski

 

01 Mar 2012

Create a set of objects from a text file.

| Watch this File

File Information
Description

MDC = MYDYNAMICCLASS(TEXTFILE) will create a set of class from TEXTFILE.

The file must be delimited by white spaces so for text use underscores. Do not use quotes anywhere.

The first line should begin with the Class name followed by a list of the Fields.

Each subsequent line should begin with the Member followed by the values for each of the Fields.

myDynamicClass will convert strings to numbers; and may read in arrays if they entered as strings and use commas instead of spaces.

MDC = MYDYNAMICCLASS(TEXTFILE,FORMAT) creates the file using a FORMAT string that conforms to the standard MATLAB textscan notation.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File  
Everyone's Tags
class, data import, objects, oop
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
02 Mar 2012 Mark Mikofski

Using JSON is a more standardized way to convert text and text files to structures (or objects). XML is of course another standard and it is built into MATLAB, but it can be more effort than parsing JSON,
Here is a MATLAB JSON parser By Q Fang:
http://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab-a-toolbox-to-encodedecode-json-files-in-matlaboctave
Also see these JSON references:
http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc
http://json.org/
http://www.mathworks.com/matlabcentral/fileexchange/20565
http://www.mathworks.com/matlabcentral/fileexchange/23393
Here are some XML references:
http://www.mathworks.com/help/techdoc/ref/xmlread.html
http://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct
http://www.mathworks.com/matlabcentral/fileexchange/28639-struct2xml

Contact us