Matlab cannot be found

I am using ubuntu 20.04 and Matlab 2021a. I can use Dynare with GNU Octave. But when I install dynare-matlab I get the following error:

Setting up dynare-matlab (4.6.0+dfsg-2) …
Building Matlab extensions (logfile at /tmp/dynare-matlab-mexbuild-1622725465.xIjeoTm)
configure: error: MATLAB cannot be found
dpkg: error processing package dynare-matlab (–configure):
installed dynare-matlab package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
dynare-matlab
E: Sub-process /usr/bin/dpkg returned an error code (1)

If I run dynare within Matlab, I get the following error:

Warning: Name is nonexistent or not a directory: /usr/lib/dynare/matlab/…/mex/matlab
In path (line 109)
In addpath (line 86)
In dynare_config (line 160)
In dynare (line 74)

And also:

Unrecognized function or variable ‘num_procs’.

Error in default_option_values (line 72)
options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = num_procs;

Error in global_initialization (line 122)
options_ = default_option_values(M_);

Error in myFile.driver (line 24)
global_initialization;

Error in dynare (line 301)
evalin(‘base’,[fname ‘.driver’]) ;

How can I link Dynare to Matlab?

Did you specify the --with-matlab-flag? See Dynare / dynare · GitLab

Thank you. I followed the instructions and it seems to work. However, when I do make check I got that the “Ramsey_Example_estimation.mod” does not work. Is this normal or does it imply that I will not be able to use the Ramsey optimal policy commands?

================================
DYNARE MAKE CHECK MATLAB RESULTS

| TOTAL: 1324
| PASS: 1298
| FAIL: 7
| XFAIL: 19
| XPASS: 0
|
| LIST OF FAILED TESTS:
| * TeX/fs2000_corr_ME.mod
| * gsa/ls2003.mod
| * optimal_policy/Ramsey/Ramsey_Example_estimation.mod
| * identification/as2007/as2007.mod
| * identification/correlated_errors/fs2000_corr.mod
| * shock_decomposition/ls2003_plot.mod
| * run_reporting_test_matlab.m
|
| LIST OF 10 SLOWEST TESTS:
| * shock_decomposition/ls2003_plot.mod - 172.184049
| * gsa/ls2003.mod - 132.688137
| * k_order_perturbation/burnside_k_order.mod - 127.524626
| * particle/dsge_base2.mod - 123.401148
| * pac/trend-component-28/example4.mod - 79.605675
| * TeX/fs2000_corr_ME.mod - 76.081274
| * observation_trends_and_prefiltering/MCMC/Trend_no_prefilter_MC.mod - 66.096667
| * pac/trend-component-25/example1.mod - 63.407376
| * conditional_variance_decomposition/example1.mod - 63.110894
| * observation_trends_and_prefiltering/MCMC/Trend_loglinear_no_prefilter_MC.mod - 62.471788

make[2]: *** [Makefile:1613: check-matlab] Error 1
make[2]: Leaving directory ‘/home/default/dynare/tests’
make[1]: *** [Makefile:1023: check-am] Error 2
make[1]: Leaving directory ‘/home/default/dynare/tests’
make: *** [Makefile:422: check-recursive] Error 1

You need to try. It seems that all files failed that try to compile \LaTeX-code. That would not affect you ability to run Dynare itself.

1 Like

Hi, I have the same problem, but do not understand the proposed solution. In particular, how can I specify the --with-matlab flag? From what I understood from the config.log file, it seems that it is indeed mispecifed:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by dynare configure 4.6.0, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure --with-matlab=/usr/local/MATLAB/R2021a MATLAB_VERSION=

When using the Ubuntu package dynare-matlab, you’re not supposed to directly pass the --with-matlab flag. It is done automatically.

I guess something is wrong with your configuration or your installation in relation to MATLAB. Can you send the output of:

update-alternatives --display matlab

Thank you for your answer. Here is the output:

update-alternatives --display matlab
matlab - auto mode
link best version is /usr/local/MATLAB/R2021a/bin/matlab
link currently points to /usr/local/MATLAB/R2021a/bin/matlab
link matlab is /usr/bin/matlab
slave matlab-mbuild is /usr/bin/matlab-mbuild
slave matlab-mex is /usr/bin/matlab-mex
/usr/local/MATLAB/R2021a/bin/matlab - priority 0
slave matlab-mbuild: /usr/local/MATLAB/R2021a/bin/mbuild
slave matlab-mex: /usr/local/MATLAB/R2021a/bin/mex

Ok so that seems correct.

Can you rerun (as root): dpkg-reconfigure dynare-matlab

In particular, this will create a log file (whose name will be displayed). Can you send it to me by private message?