Hello everyone
I just started, coding by IT + +, and I want if it's possible to do this in IT++
for i=1:10
Mat3d(:,:,i) = Mat2D;
end
thank you for your help
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you are not providing too much details on your problem... I will guess some parameters of yours: You want to construct an equivalent to a 3D array with complex elements. Furthermore you would like to assign a 2D matrix to the array in distinct position.
A code snippet:
Array<mat> my_3D_array(length); // length corresponds to the max of yout counting variable i, i.e. 10
mat my_2D_matrix(size_m, size_n); // size_m/n are obviously the dimensions of the 2D matrix
// assume having calculated with (especially initialised) the 2D matrix
// Then you can assign this matrix to the array according to your example
for (int i = 0; i < 10; i++){
my_3D_array(i) = my_2D_matrix;
}
That's it. Hope this helps.
BTW: This forum is on open discussions, but you are asking for help. You might receive more answers next time by posting to the help forum :-)
Regards,
donludovico.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The drawback of using Array<mat> is that you cannot do something like
Mat3d(:,i,:) = Mat2D
if you need to.
For that I think that you would need some kind of "three dimensional container", instead of a "one dimensional container" where each element is a "two dimensional container".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone
I just started, coding by IT + +, and I want if it's possible to do this in IT++
for i=1:10
Mat3d(:,:,i) = Mat2D;
end
thank you for your help
Hi BALLIHI,
you are not providing too much details on your problem... I will guess some parameters of yours: You want to construct an equivalent to a 3D array with complex elements. Furthermore you would like to assign a 2D matrix to the array in distinct position.
You can do this by using the array<mat> class. You find very good information about this in the getting started guide:
http://itpp.sourceforge.net/current/users_guide.html#array_class
A code snippet:
Array<mat> my_3D_array(length); // length corresponds to the max of yout counting variable i, i.e. 10
mat my_2D_matrix(size_m, size_n); // size_m/n are obviously the dimensions of the 2D matrix
// assume having calculated with (especially initialised) the 2D matrix
// Then you can assign this matrix to the array according to your example
for (int i = 0; i < 10; i++){
my_3D_array(i) = my_2D_matrix;
}
That's it. Hope this helps.
BTW: This forum is on open discussions, but you are asking for help. You might receive more answers next time by posting to the help forum :-)
Regards,
donludovico.
I have the same problem.
The drawback of using Array<mat> is that you cannot do something like
Mat3d(:,i,:) = Mat2D
if you need to.
For that I think that you would need some kind of "three dimensional container", instead of a "one dimensional container" where each element is a "two dimensional container".