Code Directory
 Visual Basic & VB.NET
New Code
GetOrgChart 2.5.3
AnyGantt JS Gantt Charts 8.6.0
AnyChart JS Charts and Dashboards 8.6.0
Multi Vendor Ecommerce Script & Apps 4.0
Magento 2 Inventory Management Extension 1.0
Yipit Clone Script - Daily Deals Software 1.0.2
Devart Excel Add-in for Oracle 1.7
Devart Excel Add-in for Freshdesk 1.7
Devart Excel Add-in for G Suite 1.7
C# QR Code Generator
Salesforce WordPress Customer Portal 3.2.0
Single Leg MLM 1.2.1
OzGIS 14.6
Quick Maps For Dynamics CRM 3.1
Job Board Software 4.2
Top Code
MCU 8051 IDE 1.4.7
shopping mall management system 1.0
WinPoker 2.02
MATLAB Support Package for Arduino (aka ArduinoIO Package) 1.0
SynaSer Serial Port Library 5.0
MLM Software 1.0.2
sipmethod 1.0
STDF file reader 1.0
Maios 1.0
School Management Script 1.0.4
jArt Java Operating System 1.0
Planyo online reservation system module 6.x-1.8
Bank Transfer 6.x-1.x-dev
Azizi search engine script PHP 4.1.10
SuperGeek Free Document OCR 2.5.6
Top Rated
VisualNEO Web 2018.12.15
Paste phpSoftPro 1.4.1
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
PHP GZ Blog Script 1.1
ATN Jobs Software 4.0
Pack & Unpack variables to & from structures with enhanced functionality 1.0
File ID: 83777

Pack & Unpack variables to & from structures with enhanced functionality 1.0
Download Pack & Unpack variables to & from structures with enhanced functionality 1.0http://www.mathworks.comReport Error Link
License: Shareware
File Size: 20.5 KB
Downloads: 1
Submit Rating:
Pack & Unpack variables to & from structures with enhanced functionality 1.0 Description
Description: v2struct has dual functionality in packing & unpacking variables into structures and vice versa, according to the syntax and inputs.

Function features:
* Pack variables to structure with enhanced field naming
* Pack and update variables in existing structure
* Unpack variables from structure with enhanced variable naming
* Unpack only specific fields in a structure to variables
* Unpack without over writing existing variables in workspace

In addition to the obvious usage, this function could by highly useful for example in working with a function with multiple inputs. Packing variables before the call to the function, and unpacking it in the beginning of the function will make the function call shorter, more readable, and you would not have to worry about arguments order any more. Moreover you could leave the function as it is and you could pass same inputs to multiple functions, each of which will use its designated arguments placed in the structure.

Moreover, the function enables extracting specific fields from a structure according to field names. This enhances the flexibility and ease of use of structures, for example it allows you to pass same inputs as structures to multiple functions, each of which will use its designated
arguments placed in the structure.

Some examples:
Simple pack:
x = zeros(3);
y = 'Testing123';
z = cell(2,3);
fieldNames1 = {'fieldnames','x','y','z'};
fieldNames2 = {'fieldnames','a','b','c'};

>> S = v2struct(x,y,z)
S =
x: [3x3 double]
y: 'Testing123'
z: {2x3 cell}

pack with different field names:
>> S = v2struct(x,y,z, fieldNames2)
S =
a: [3x3 double]
b: 'Testing123'
c: {2x3 cell}

update existing structure with additional field:
>> S.oldField = 'field to be saved for future use'
>> S = v2struct(x2, nameOfStruct2Update, fieldNames3)
S =
oldField: 'field to be saved for future use'
x: [3x3 double]

simple unpack:
S.x = zeros(3);
S.y = 'Testing123';
S.z = cell(2,3);
fieldNames3 = {'y'};
>> v2struct(S)
y =

More examples, further comments and demo usage are available inside the .m file and the demo functions.

Comments, suggestions, bug reports and any other feedback is welcomed at adi.navve[at]gmail[dot]com

Inspired by the function 'mmv2truct' from the Mastering Matlab Toolbox (available free) by D.C. Hanselman, University of Maine, Orono, ME 04469 4/28/99, 9/29/99, renamed 10/19/99 Mastering MATLAB 5, Prentice Hall, ISBN 0-13-858366-8
available at:

License: Shareware

Related: structx, nameofstruct update, use039, future, saved, fieldnames, oldfield, structs, Testing, 039y039

O/S:BSD, Linux, Solaris, Mac OS X

File Size: 20.5 KB

Downloads: 1

More Similar Code

An Introduction to XML Templates with SQL Server 2000 is an simple and easy to understand tutorial through which the programmers can get details about easy methods of using XML templates in SQL server 2000. From this artcile they can also learn about several template parameters, about the method of accessing the SQL data over HTTP etc.

Downloading files to the browser with ADODB.Stream is an online article in which the author has narrated on the techniques of using ASP functions in getting the properties of files like the size, name and type etc., You would also be able to...

Intro to DB Programming with ASP is a tutorial which teaches basic database programming for the beginners. This tutorials guides the users to insert and access records in the database with ease. By the end of this article novice can able to...

Posting to a URI with a Web Client is an article in which author explains about creating a web client and the aspects of using the web clients to send the messages to a URI that is specified in the code. Here the author describes about code that...

DMB Dynamic Buttons is an easy to use tool with enhanced features. Using this ASP.NET based utility you can save time by creating multiple images from a single image easily. You can place the text in any postion as well as you can set different...

mxLogicalFunctions.for provides a suite of functions to support conversion of Fortran logical variables to/from MATLAB style mxArray variables in mex routines or engine applications. Assumes that the MATLAB logical class uses 1 byte for storage of...

This article is helpful for the users which gives elaborate definitions to the users about SQL apostrophes bug fix. This tutorial also has given solution to the users for replacing strings or variables to SQL statements with sample code.

Now, you can enlarge your desktop twice or more (up to eight times) easily. The designation of MSEW is to provide you with the functionality of having extra desktops with running applications simultaneously. This is very easy in use and good in...

Visitor Information Graphic is an easy to use tool with enhanced features. Using this tool you can view your website visitors computer name, IP address, proxy settings and browser name in a graphical display easily. This software is written in...

RawLine is a 100% Ruby library able to provide some of the functionality offered by ReadLine, plus additional features such as a more intuitive way to bind characters to specific keys and full access to command history.

User Review for Pack & Unpack variables to & from structures with enhanced functionality
- required fields

Please enter text on the image