How do I concatenate two MX arrays in a MEX-file that emulates the HORZCAT command of MATLAB?

5 views (last 30 days)

Accepted Answer

MathWorks Support Team
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".

More Answers (0)

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!