This has stumped me for the past week, but I think I have it cracked. (At least, this makes sense for my application, which is controlling Siemens Solid Edge ST2 via the COM API. Hopefully you can confirm for your application?)
Visual Basic has the shorthand For Each Object In CollectionClass, which takes advantage of a special field (attribute) Count and a method Item() belonging to "collection class" objects, which are designed to collect other objects (cells in a spreadsheet, 2D lines in a CAD drawing, etc.) See the MSDN reference below.
The field Count just returns the number of Objects in the CollectionClass (an integer), and the method Item(i) returns the i'th Object in the CollectionClass. (In your case, the i'th Order in the Query collection class.)
So to replicate in MATLAB, you would do:
objQuery = CQG.ICQGOrdersQuery ;
nOrders = objQuery.Count ;
for k = 1:nOrders, ;
objOrder = objQuery.Item(k) ;
Like I said, this works for my problem, trying to loop through things like reference planes, lines, circles, etc. via the COM API for Solid Edge. Let me know if this makes sense for you!