View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Parse property/value pairs and structures

5.0 | 4 ratings Rate this file 3 Downloads (last 30 days) File Size: 2.05 KB File ID: #22671 Version: 1.0

Parse property/value pairs and structures



Parses property/value pairs just like Handle Graphics functions.

| Watch this File

File Information

This function can be used to parse property/value pairs just like Handle Graphics functions which means that it can also handle structures with field names that are property names.


Parse Pv Pairs inspired this file.

This file inspired Qr Code Encoder.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Should work in any MATLAB version that supports structures, cell arrays and varargin.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
06 Apr 2014 Douglas Schwarz

Adding error IDs is a great idea -- I'll do that. I don't know about providing for objects though. My intent is make it accept property/value pairs just like Handle Graphics functions so that includes structures. If HG functions accept objects then I'll add that, but I wouldn't think there'd be much call for it. Thanks for your comments!

Comment only
01 Apr 2014 Matthew Barrett

This is an excellent submission, thank you!

I've made one minor extension in my version which allows this function to work with objects as well as structures. I haven't encountered any bugs because of it yet, but I can't guarantee that it's error free.

You could change the line:

elseif isstruct(arg)


elseif isstruct(arg) || isobject(arg)

For completeness/tidiness, you could also change the errors to include IDs (to allow user control of error management), so something like...

error('ParsePropVal:BadArgFormat', 'Properties must be specified by property/value pairs, structures, or objects.')


error('ParsePropVal:BadArgValue', 'Property ''%s'' does not exist or is ambiguous.', arg)

07 Apr 2011 Arthur

Arthur (view profile)

Just what I needed!

08 Feb 2010 Joshua Arnott

14 Jan 2009 John D'Errico

John D'Errico (view profile)

It took me a minute to see where this went beyond my own parse_pv_pairs, but it does offer an improvement over my code.

Contact us