I am a novice MATLAB user currently writing a resource-intensive simulation program. Its main data structure is a collection of particles having a three-component position vector and a number of other properties (the number of which is known in advance).
My first attempt was to use an array of structs for this (particles(n).x=rand(), etc...), which would work fine with a regular loop but gave an error when wrapping it in a parfor loop, which makes it seem that this is not the best approach. Furthermore, I would like to move part of the calculations to the GPU at a later time, which seems impossible using the struct array. What would be the preferred way of organizing such a data structure in MATLAB?