How do I concatenate two MX arrays in a MEX-file that emulates the HORZCAT command of MATLAB?
5 views (last 30 days)
Show older comments
I would like to concatenate two MX arrays in a MEX-file to emulate the HORZCAT functionality of MATLAB.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
There are no MX array manipulation functions that emulate the HORZCAT functionality of MATLAB. However, it is possible to use the MXREALLOC and MEMCPY functions to achieve the desired functionality. The attached C MEX-file example concatenates two MX arrays using the above functions.
To compile this code in MATLAB, perform these steps:
1. Select a compiler by issuing the following at the MATLAB Command Prompt:
mex -setup
2. Issue the MEX command:
mex mx_concatenate.c
3. To execute this function within MATLAB, issue the following at the MATLAB Command Prompt:
A=rand(5,3);
B=rand(5,2);
C=mx_concatenate(A,B);
The variable "C" is the concatenated array of arrays "A" and "B".
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!