Hi everyone,
Is there an accepted way to test if the local Matlab instance has CVX installed?
When sharing code relying on a non-native library/package/toolbox (e.g. CVX) I find it best practice to include the installation check and give the user a meaningful warning/error if the prerequisite is not installed.
Otherwise the user is left in the dark with a lot of question marks about pretty obscure errors. (which is how I discovered CVX in the first place )
What I came up by glancing over CVX’s files is something like :
try
global cvx___;
cvx_version(1); %Goes to catch if cvx_version is not known.
if ~cvx___.loaded
%if CVX is installed correctly, this variable should be true after calling cvx_version()
%Otherwise we end in the catch block
error();
end
catch
warning("No valid CVX installation found. This may cause unexpected behavior. Get CVX: https://github.com/cvxr/CVX")
end
Is there any agreed “best way” to achieve this? Can my solution run into issues of the kind “…but it works on my machine!”, especially when dealing with different platforms such as windows and linux?