7 views (last 30 days)

For Mac Users, I need that info. Thanks

Walter Roberson
on 20 Jun 2019

Your SegmentBoneDP.cpp file is the source code.

If you need something that converts C++ code into MATLAB code, then you are using the wrong product family. There is no known program that converts C++ code into MATLAB code.

"The point is that I don't know the number and type of inputs the function requires since I cannot open it to see it. "

You read them out of the C++ source code.

Bness = (double *)mxGetData(prhs[0]);

double *pF0,*pF1,*pBth,*pJumpConst;

pF0 = (double *)mxGetData(prhs[1]);

pF1 = (double *)mxGetData(prhs[2]);

pBth = (double *)mxGetData(prhs[3]);

pJumpConst = (double *)mxGetData(prhs[4]);

The first parameter is Bness, and is a 2D double array.

The second parameter is F0, and it is a double scalar. It appears to be used as a weight or smoothing factor

The third parameter is F1, and it is a double scalar. It appears to be used as a weight or smoothing factor

The fourth parameter is Bth, and it is a double scalar. It is a threshold between bone and no bone.

The fifth parameter is JumpConst, and it is a double scalar. It appears to be some kind of penalty for moving from bone to no bone.

The output is an array the same size as Bness, and it is a real double 2D array.

Jan
on 19 Jun 2019

Edited: Jan
on 19 Jun 2019

Wow, what an inefficient communication.

As Walter has said already, the line

const int *DimsBness;

must be changed to

const mwSize *DimsBness;

This might matter other variables of the type int also.

C++ Mex files are compiled to mexmaci64 files. Of course you can neither edit these output files, not run it directly. This is the nature of compiled files. Simply put this file to a folder, which is included to your Matlab path and call it like any other function stored in an M-file:

result = BoneSegmentationDP(args)

where args are the 5 needed inputs.

"I was getting the error message that I needed to update my Xcode compiler in order to utilize the new API, that's why I used mex -compatibleArrayDims BoneSegmentationDP.cpp"

No. If you get the message, that the Xcode compiler needs an update, update the Xcode compiler. It is off-track to play around with the compatibleArrayDims flag.

Walter Roberson
on 23 Jun 2019

Everyone gets that warning. It has nothing to do with you using Mac or any particular xcode version.

Walter Roberson
on 23 Jun 2019

mwSize is size_t which is unsigned long long for your system. It causes 8 bytes to be reserved for each variable that is to store an array size. That permits arrays larger than 2 gigabytes. Your existing use of int for the size is reserving only 4 bytes for array sizes.

Now you might be thinking that your particular use never involves arrays 2 gb or larger and you might be thinking that means that you do not need to use the larger variable. However 8 bytes is what matlab uses internally now and when matlab builds its internal description of the parameters to the call it is going to allocate memory based on the larger size. If your code were to try to use the sizes as if only 32 bits were allocated for the size then you would be looking for the second dimension size at the wrong place in memory.

Walter Roberson
on 23 Jun 2019

"Where do I replace them? In the C++ code?"

Yes. Edit the darn C++ code.

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 14 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715887

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715887

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715888

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715888

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715893

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715893

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715939

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715939

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715943

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_715943

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716070

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716070

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716079

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716079

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716084

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716084

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716088

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716088

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716097

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716097

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716128

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716128

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716255

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716255

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716336

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716336

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716464

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/467674-how-do-i-convert-to-mex-from-cpp-using-xcode-ver-10#comment_716464

Sign in to comment.