1

Is there a difference between a 1x3 structure array and a 3x1 structure array? From what I can see, there doesn't appear to be but I'm not entirely sure.

1 Answer 1

2

Yes there is a difference, but it will only matter some of the time. This holds true for numeric arrays as well so I will use these in my examples below for brevity.

For linear indexing it won't matter whether for a row or column vector.

a = [4, 5, 6];
b = a.';

a(1) == b(1)
a(2) == b(2)
a(3) == b(3)

If you use two dimensions to index it though, it will matter.

% Will work
a(1, 3)

% Won't work
a(3, 1)

% Will Work
b(3, 1)

% Won't work
b(1, 3)

The biggest time it matters is when you go to combine it with another struct. The dimensions must allow for concatenation.

a = [1 2 3];
b = a.';

% Cannot horizontally concatenate something with 1 row with something with 3 rows
[a, b]

% You need to make sure they both have the same # of rows
[a, a]   % or [a, b.']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.