필터 지우기
필터 지우기

help with Compiling a mex-file

조회 수: 53 (최근 30일)
Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019년 6월 3일
댓글: Walter Roberson 2023년 9월 13일
hello Folks,
I downloaded a Matlab package for probabilistic modeling of circular data with mixtures of von Mises distributions.
please see this link
in the installation phase i have to do this :
  1. Clone or download this repository and add it to your MATLAB search path.
  2. Compile the *.mex-file located at @VonMisesMixture/private by browsing to that directory in MATLAB and running mex sampleVonMisesMex.c from the command line.
i didn't understand how to do the second step if any one can help

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 3일
cd to the directory that you downloaded the code into.
Give the command
mex sampleVonMisesMex.c
If the compiling works then the routine should be ready to use, callable under the name sampleVonMisesMex
Before doing all of this you need to have installed a support compiler for your operating system and release, and have given the command
mex -setup c
and chosen a compiler if more than one is offered.

추가 답변 (2개)

Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019년 6월 3일
i got this error
>> mex sampleVonMisesMex.c
Building with 'MinGW64 Compiler (C)'.
C:\Program Files\MATLAB\R2018b\bin\mvmdist-master\@VonMisesMixture\private\sampleVonMisesMex.c: In function 'sample':
C:\Program Files\MATLAB\R2018b\bin\mvmdist-master\@VonMisesMixture\private\sampleVonMisesMex.c:54:32: warning: implicit declaration of function 'random' [-Wimplicit-function-declaration]
srand( time(NULL) + clock() + random() );
^~~~~~
Error using mex
C:\Users\mbenm\AppData\Local\Temp\mex_10616001118706_3404\sampleVonMisesMex.obj:sampleVonMisesMex.c:(.text+0x65):
undefined reference to `random'
collect2.exe: error: ld returned 1 exit status
would you please tell me what to do ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 6월 3일
Hmmm, I do not know where they are expecting to get random() from. random() is not part of the C language standard. C++ has a header named "<random>" but none of the functions are named random()

댓글을 달려면 로그인하십시오.


Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019년 6월 3일
so what to do? any suggestions?
  댓글 수: 5
Richard Cui
Richard Cui 2023년 9월 13일
Modify random() to rand(), which will do the work.
Walter Roberson
Walter Roberson 2023년 9월 13일
time() returns a time_t (data type not specified by C standard, but often some form of integer)
clock() returns a clock_t (data type not specified by C standard, but often some form of integer)
random() returns an int (not a long int)
The sum of those three is not well defined in type.
srand() requires an unsigned int parameter.
It is not obvious that adding those three types gives an appropriate parameter for srand()

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by