File Exchange

image thumbnail

transpose_structure

version 1.1 (1.32 KB) by

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

0 Downloads

Updated

View License

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)

Comments and Ratings (1)

Jan Simon

Jan Simon (view profile)

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

1.1

replaced length() by numel()

MATLAB Release
MATLAB 7.10 (R2010a)
Tags Add Tags

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

» Watch video