Exractin 3D matrix from 4D
Oct 20, 2022 at 2:21pm UTC
Hello everyone,
I will be very happy if you can help me. I have 4D matrix , which is called EC and like EX[p][a][b][c]. I want to extract 3D matrix of each p like New_EC=[a][b][c] for any p. I tried the following but did not work.
Thank you so much for any help in advance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
vector<vector<vector<double >>>sum_temp;
for (int j = 0; j < EC[p].size(); j++)
{
vector<vector<vector<double >>>sum_temp;
for (int s = 0; s < EC[p][0].size(); s++)
{
vector<vector<double >>EC_2D;
for (int ss = 0; ss < EC[p][s][0].size(); s++)
{
vector<int >ECvv;
for (int ks = 0; ks < EC[p][s][0].size(); s++)
{
ECvv.push_back(EC[p][j][s][ss]);
}
EC_2D.push_back(ECvv);
}
}
sum_temp.push_back(EC_2D);
}
Oct 20, 2022 at 4:47pm UTC
Doesn't
auto the_nth_3d_matrix = the_4d_matrix[n];
do what you want?
Last edited on Oct 20, 2022 at 4:49pm UTC
Oct 21, 2022 at 9:52am UTC
@mbozzi ,yes, exactly. That's what I want. You helped me :) Thank you so much
Topic archived. No new replies allowed.