I have a struct called A which has a [1x1] struct called B, and when I run A.B in the command line, it returns two types of answers:
ans =
X: 3
Y: 2
Z: 4
ans =
X: 1
Y: 5
Z: 9
W: 4
V: 2
EDIT: What I'm trying to do is put all the values of X into a vector, so that the vector would look something like this: [3, 1, ...]
To do so, I'm first creating a vector called AB so that I can put [AB.X] into a another vector that I can use.
My current strategy is running a for loop like this one:
for idx = 1:length(A)
AB(idx) = [A(idx).B];
end
But I get an error, "Subscripted assignment between dissimilar structures." I think that's because some values of B have 3 parts while others have 5.
How can I resolve this?
Or is there a way better than using a for loop?
struct? You are getting that when doingA.BbecauseAis a two element struct. The firststructelement has three fields while the other element has five. By doingA.Byou are unpacking all of thestructs and it has nowhere else to go, so it floods the command prompt with eachstruct. - rayryeng