Code covered by the BSD License  

Highlights from
transpose_structure

Be the first to rate this file! 13 Downloads (last 30 days) File Size: 1.32 KB File ID: #40142

transpose_structure

by

 

01 Feb 2013 (Updated )

transpose_structure(s) transposes all the fields in the structure. useful for later cat(1,s.field)

| Watch this File

File Information
Description

Users that often use cat(1,s.field) find annoying that this function generates error if the field is in different orientation (row or column vector). Instead of try ... catch, it's suggested to use transpose_structure(s).

>> s = struct('x',ones(10,1),'y',zeros(5,1));
>> s = transpose_structure(s)

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
05 Feb 2013 Jan Simon

This line considers only all elements of the inputs struct s, when it is a vector:
for i = 1:length(s)
To consider all elements in arrays using linear indexing:
for i = 1:numel(s)

Updates
05 Feb 2013

replaced length() by numel()

Contact us