Why Matlab give me this warning?
Show older comments
Hi everybody, I need help! I'm not able to use matlab… but i need it. Matlab R2017b is installed on Win 10. I have this function from academic literature. But i didn't understand what means '%call Fortran 90 MEX function'. In particular, when I run the function, matlab Give me the advice: -------
Undefined function or variable 'tnn13'.
Error in fnn_mex2 (line 40)
nnmat=tnn13(xcoord,ycoord,ms,n,istart);
Error in x_spatiotemporal2 (line 79)
nnmat=fnn_mex2(xcoord, ycoord, ms, n, istart);
------
The undefined function is a .dll file which is in the folder.
Below you can see the function.
-----
function tnnmat=fnn_mex2(xcoord, ycoord, ms, n, istart)
%
%tnnmat=fnn_mex2(xcoord, ycoord, ms, n, istart)
%
%This function computes m spatiotemporal nearest neighbors for each observation from observation 1 to (n-istart).
%This matlab function calls a Fortran 90 Mex function, tnn13.dll. For other platforms, the fortran source code is
%available in a subdirectory within the space_time subdirectory under the examples subdirectory.
%
%INPUT:
%
%xcoord, ycoord are n by 1 vectors ordered by time with observation 1 the most recent and observation n the oldest.
%
%ms is the number of nearest neighbors previous in time
%
%n is the number of observations
%
%istart is where to begin computing temporal nearest neighbors. This allows istart observations to exist before beginning,
%and istart>ms.
%
%
%OUTPUT:
%
%tnnmat is a n by ms matrix of spatiotemporal nearest neighbors.
%
%
%NOTES:
%
%
%A similar function was used in:
%
%Pace, R. Kelley and Ronald Barry, O.W. Gilley, C.F. Sirmans,
%“A Method for Spatial-temporal Forecasting with an Application to Real Estate Prices,”
% International Journal of Forecasting, Volume 16, Number 2, April-June 2000, p. 229-246.
%
%Written by Kelley Pace, www.spatial-statistics.com, 1/08/03.
%increase m by 1 to allow for non-own neighbors
ms=ms+1;
%call Fortran 90 MEX function
nnmat=tnn13(xcoord,ycoord,ms,n,istart);
%transpose and eliminate index to own observation
nnmat=nnmat';
tnnmat=nnmat(:,2:end);
----
Thank you very much!!
F
2 Comments
Geoff Hayes
on 12 Jun 2018
Federico - please clarify what you mean by The undefined function is a .dll file which is in the folder. Do you see a file named tnn13.dll? I suspect that you should have some sort of Fortran source MEX file (see Create Fortran Source MEX File) that the above MATLAB code will call. The error message is indicating that tnn13 function cannot be found so ensure that it is in the MATLAB path.
Federico Dell'Anna
on 12 Jun 2018
Answers (1)
If it is really a ".dll" file, it is outdated for a long time. Modern compiled Mex functions have the extension as e.g. '.mexw64'. You will not be able to run the old DLLs anymore. As far as I remember the format changed with R2007b.
Do you have the Fortran source codes? Then you can compile them again, considering, that you have a Fortran compiler.
5 Comments
Federico Dell'Anna
on 12 Jun 2018
Then you have to compile the files. You need a Fortran compiler, which is compatible to your Matlab version. See R2017b: Supported Compilers : E.g. "Intel Visual Fortran Composer XE 2013", which requires in addition a Professional version of MS Visual Studio 2013 or 2015, or the 2017 family.
Federico Dell'Anna
on 17 Jun 2018
Jan
on 17 Jun 2018
Walter Roberson
on 17 Jun 2018
Note: unfortunately g77 / gfortran is not supported on Mac; only the Intel Fortran compiler is supported on Mac. If I recall correctly, students can use the Intel compilers for no cost, but otherwise they are a bit costly.
See https://www.mathworks.com/matlabcentral/answers/338303-how-to-set-up-mex-with-gfortran-on-mac#answer_285758 for discussion of use of gfortran. I did get it to compile my test code, but I did not get it to execute properly.
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!