For example, if I have
vec a(3, fill::randu);
vec b(5, fill::randu);
How can I get a new vector c of size 8, where the first three elements are from a and the rest from b?
The concatenation of vectors can be done by using combination function c. For example, if we have three vectors x, y, z then the concatenation of these vectors can be done as c(x,y,z). Also, we can concatenate different types of vectors at the same time using the same same function.
To concatenate a vector or multiple vectors in R use c() function. This c() function is used to combine the objects by taking two or multiple vectors as input and returning the vector with the combined elements from all vectors.
The Vector Concatenate and Matrix Concatenate blocks concatenate input signals to create a nonscalar signal that you can iteratively process with a subsystem, for example, a for-each, while-iterator, or for-iterator subsystem. In the Simulink® library, these blocks are different configurations of the same block.
You can use join_cols(a,b)
since vec
inherits from mat
#include<armadillo>
using namespace arma;
int main()
{
vec a(3, fill::randu);
vec b(5, fill::randu);
vec c;
c = join_cols(a,b);
a.print("a");
b.print("b");
c.print("a..b");
return 0;
}
...gives the output
a
0.8402
0.3944
0.7831
b
0.7984
0.9116
0.1976
0.3352
0.7682
a..b
0.8402
0.3944
0.7831
0.7984
0.9116
0.1976
0.3352
0.7682
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With