Matlab 2019 gives abnormal errors when launching - matlab

I have just downloaded Matlab toolbox and I think I did a mistake somewhere but don't know where. I have two versions of Matlab on my machine and I when I launch Matlab 19, the one I want to use, I get this two lines of error:
Unable to resolve the name slreq.utils.loadLinkSet.
Error in rmiml.getAll
When I run the first section, which is merely
clear all; close all; clc;
I get this error
Cannot find builtin function '_LiveEvaluate'
I really don't know what happened and how I could solve it. I have checked the environment variables and they seem okay.
When I run the whole script (without doing by section), I have this error occurring
Attempt to execute SCRIPT mrdivide as a function:
C:\Program Files\MATLAB\R2019b\toolbox\matlab\ops\mrdivide.m
Error in Sandbox (line 25)
X=1/2*eye(n);

Related

Error when opening script in Matlab R2020a

I try to use a Matlab script written by someone else in my reasearch group a couple of years ago. This person is not in the group anymore.
If I open the script (double click on it on Windows Explorer), Matlab starts and before even running the script or doing anything else I immediately get these 5 error messages (as pop-up windows, not as an output in the console):
Error using matlab.internal.editor.OutputPackager
Error: File: OutputPackager.p Line: 63 Column: 0
The import statement 'import.matlab.internal.editor.StdoutOutputPackager' cannot be found or cannot be imported. Imported names must end with '.*' or be fully qualified.
Unrecognized function or variable 'matlab.internal.addons.updates.getSupportPackageUpdates'.
Unrecognized function or variable 'matlab.internal.addons.updates.getSupportPackageUpdates'.
Unrecognized function or variable 'matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip'.
Unrecognized function or variable 'matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip'.
I use Windows 10, 64 bit and Matlab R2020a Update 5.
Unfortunately, I cannot upload the file here and I am not able to produce a reproducible example (all my other files open normally). I also tried restarting Matlab and restarting my computer.

Matlab Unknown class error after compiling script containing TCPIP

I compiled a script that uses the tcpip function from the instruments toolbox using MCR_R2015a. Running the generated executable on the PC I used for compiling (Windows7) is not a problem, however running it on another PC (Windows10, no Matlab installed) is. I receive the following error:
unknown variable com or unknown class com.mathworks.toolbox.instrument.TCPIP
pointing to line 123 in tcpip. The surrounding code is:
try
obj.jobject = handle(com.mathworks.toolbox.instrument.TCPIP(host,port));
catch aException
newExc = MException('instrument:tcpip:cannotCreate',aException.message);
throw(newExc); %%% this is line 123
end
Obviously com.mathworks.toolbox.instrument.TCPIP is not known. I tried to find the file defining this object to append it when compiling without success.
Where to find that file or how to compile a running executable?
As I was able to run the script inside Matlab but not the executable using the Matlab compiler runtime, I figured an unset path in the MCR may cause the error.
Not being able to find the file were the path to the TCPIP class is defined, I ended up deinstalling the MCR. Et voilá, it worked!
I am aware this solution is not answering the question how to compile scripts containing the tcpip function and running the generated exe on PCs that have no Matlab installed. But it is good enough for me.

Running external program in Matlab fails but program works outside it

I need to use a toolbox in Matlab that depends on a external program written in C and using OpenCV. I'm using Ubuntu 14.04 64 bits and Matlab R2014b.
The m-script calls it with the system function and after the C program runs, it reads some output files that the C program should generate. This is failing to happen. I observed that the files are not being generated.
Then, the first thing I did was verify if the C program was working properly, by directly calling it in the terminal, with the same parameters that the m-script has used to call it. Then it worked and the files where generated. Thus, the C program is correct and working.
Coming back to Matlab, it failed again. Then, I started debugging the C program and had find out that the OpenCV function cvLoadImage is failing to open the file, when called from Matlab. It works if I call it outside.
I verified the string that is passed to the function both running from Matlab and externally and it is rigorously the same, but the Matlab call fails ever. I verified with ldconfig -p | grep opencv from the Matlab command window and it shows the libraries. More amusing, there are other calls to other ocv functions before the problematic one that are working. Just this is failing.
The question is: is this a problem of some misconfiguration of my part or maybe it is a bug in Matlab?
Thanks in advance.
EDIT
Actually, calling from inside Matlab with sudo appended to the system call got the job done. What is strange, because I used chmod 777 -Rf as last resource in the whole folder and verified that my user was the owner of both the folder and Matlab processes. Strange... It stills bothers me having to type my password whenever I use the script though, but my schedule is tight, I'll consider this workaround as satisfactory by now.
Instead of calling the C function from MATLAB, you can try to call MATLAB from your C code with MATLAB Engine API for C:
https://es.mathworks.com/help/matlab/calling-matlab-engine-from-c-programs-1.html

New to Matlab - Not sure how to run these files

The files I would like to run are found here:
http://www.mathworks.co.uk/matlabcentral/fileexchange/12552-multicanonical-monte-carlo-scheme-for-finding-rare-growth-factors/content/mcmc2.m
it consists of 3 files, one of which is called a driver.
I have tried running each individual one in Matlab and each one gets an error, I think this is because I need to run them all simultaneously or something?
At the beginning of the driver script it says "This is the driver script to be run from the command line. Also requires functions mcmc1 and mcmc2". Where mcmc1 and mcmc2 are the other two files I tried running it in command line but I kept getting error messages..
Any idea how I get these files to run?
You should just be able to run gf_mmc_driver from the command line in Matlab. The mcmc1.m and mcmc2.m files need to be in your matlab path, but do not need to be called directly.
However, I do notice in the driver file the following comment:
% Telling the Distributed Computing Toolbox to complete one job with
% 'numberchain' tasks. Each task is comprised of running a MCMC
% for the burnin time (mcmc1.m) with a different initial matrix.
Do you have the Distributed Computing Toolbox? The driver file appears to require it.

Parfor on a cluster : failure to recognize a function

I try to run a simple task on different machines of a cluster.
My configuration has been validated (it's ok). When I run the code
on the 'local' configuration, it works. But when I use the cluster
configuration, I get the following error :
Error using parallel_function (line 598)
Undefined function 'lafunc' for input arguments of type 'double'.
Error Stack : (No remote error stack)
Error in petittest (line 6) --» (petittest is my program's name)
parfor it=1:200
I try to modify the code to use "dfeval" instead of the parfor loop,
but I got the same kind of result (unrecognize function lafunc).
How do I get the other workers in the cluster to recognize the function
lafunc that I manually defined ?
The code is the following:
%%%%%%%%%%%%%
laconfig='/home/matlab/fred/LACED_DC1.mat';
setmcruserdata('ParallelConfigurationFile',laconfig);
matlabpool open
parfor it=1:200
yo=lafunc(it);
disp(yo)
end
matlabpool close
%%%%%%%%%%%
where the lafunc function is
%%%%%%%%%%%%%%
function [y]=lafunc(x)
y=x*x;
end
%%%%%%%%%%%%%%%%%%%%%%
Thanks a lot, every piece of info is useful to me!!
Make sure that your MATLAB script on all worker nodes running in the same working directory, and that other directories with functions you need are included in the path. So you can specifically set the working directory and path in your script:
matlabpool open
cd workdir
addpath funcdir
...
After you run matlabpool open it will run all path related commands on all workers. See here.
You can also open matlabpool with 'FileDependencies' parameter so all the workers will know where to look for required files. See the documentation for MATLABPOOL.