I am trying to figure it out how to associate each element of a one-dimensional array (let's call it array1), let's say, 4000x1, to one of the dimensions of a three-dimensional array (let's call it array2) of, let's say, 200x4x4000 elements, so that the last index of this array adquires the elements of the one-dimensional array. Without too many details, because this is nested in some for loops, what I am trying to do it is something like this:
I think that this does not work properly for my purpose, right? If that it is the case, why and how could I try to mantain the same for approach achieving what I want?
Thank you for your attention.
Edited: my problem is more intricate, and I was mistaken about which is the critical point. Let's imagine that you have the three following arrays: physical_time_elastic (2431x1 elements), file_magnetization_components_elastic (72932431x3 elements) and spatial_grid (30001x1 elements). I want to create a three-dimensional array where everything is well distributed, because my data is not well distributed coming from simulations. I want to create an array data_set_elastic (data_set_elastic=zeros(length(spatial_grid),length(file_magnetization_components_elastic(1,:))+1,length(physical_time_elastic))). Here, I want to place the data of physical_time_elastic in the third dimension of data_set_elastic. In addition, on each two-dimensional plane for each element of physical_time_elastic I want to introduce in the first element of the second index of data_set_elastic the spatial_grid array. In the rest of elements of the second index of data_set_elastic I want to place elements as follows: for the first element of physical_time_elastic the first 30001 elements of each arrow of file_magnetization_components_elastic, being, the first of file_magnetization_components_elastic the second one in the second dimension of data_set elastic, the second of file_magnetization_components_elastic the third one in data_set_elastic and the same logic for the last element of it. In the second element of physical_time_elastic, I want to place, in the second to fourth element of the second index of data_set_elastic, the elements that goes from the 30002 element of file_magnetization_components_elastic element to 60002 element, and so on up to the end of this array. To do this, I have created the following script:
Apparently, in this way, I do not obtain what I am looking for.
If someone knows how to do it with reshape, I will be happy to try to understand that approach to reduce computational time.