Code covered by the BSD License  

Highlights from
uneval

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 3.57 KB File ID: #19953

uneval

by David Holl

 

16 May 2008 (Updated 23 Jul 2012)

Uneval performs the inverse operation of eval('expression').

| Watch this File

File Information
Description

This function converts a MATLAB variable into a text string, which when evaluated, produces the original variable having identical:
data types (single, double, int8, ...)
structures
cell arrays
multi-dimensional arrays
nested struct's of cell arrays of structs of ...

For floating point values, enough significant digits are printed to preserve machine precision.

Contrived example usage:
settings = load('some_data.mat');
string = uneval('settings2', settings)
eval(string);
disp(isequalwithequalnans(settings, settings2));

This function probably does not work with handles to nested functions, figure handles, or java & OOP objects...

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
data export, data import, data structures, eval(2), eval data structures strings, strings
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
24 Jul 2012 Jan Simon

Just a comment: A shorter and faster version of your CELLSTR2STRING:
the_string = sprintf('%s\n', the_cellstr{:});

This is an interesting function. For what purpose do you use it?

15 Nov 2011 David Holl

Sorry for the omission. I just submitted an update with the missing cell_ind2sub function.

08 Jul 2011 Patrick Houweling

This function requires cell_ind2sub. Where can I get it?

Updates
15 Nov 2011

The original package was missing a misnamed subroutine called CELL_IND2SUB.

15 Nov 2011

Included missing cell_ind2sub subroutine.

23 Jul 2012

Fixed missing "end".

Contact us