title: MATLAB - How to resolve "Subscripted assignment between dissimilar structures" ERROR
body: <p>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:</p>
  
  <pre><code>ans = 
      X: 3
      Y: 2
      Z: 4
  
  ans = 
      X: 1
      Y: 5
      Z: 9
      W: 4
      V: 2
  </code></pre>
  
  <p>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, ...]</p>
  
  <p>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.</p>
  
  <p>My current strategy is running a for loop like this one:</p>
  
  <pre><code>for idx = 1:length(A)
      AB(idx) = [A(idx).B];
  end
  </code></pre>
  
  <p>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. </p>
  
  <p>How can I resolve this? </p>
  
  <p>Or is there a way better than using a for loop?</p>