While deploying packages of Matlab code using Matlab 2015 I encountered the problem of gathering all required files from my repository to run a certain file or set of files. Matlab has a method for simplifying this process, matlab.codetools.requiredFilesAndProducts.
However, sometimes some files are missing in the repository (either because I got a package from someone else who was not that careful or because it was not checked in in the repository).
When running the code one would get of course an error:
Undefined function or variable 'XXX'.
However, this may take long to fix (running takes long, you would have to repeat for every missing file). Therefore I thought to use the function above. Unfortunately, it only lists existing files in the output (I tested this). Functions that are called from your code, but that are not present in the current path are omitted by matlab.codetools.requiredFilesAndProducts.
My problem: I would like to get a list of all files that are required by running a certain file but are not present in the current path so that I can find them and add them to my collection.
I know that this must be an iterative process because the missing files could themselves call other missing files and I know that there would be false positives, some of these items could be unknown variables instead, and I know that the missing files would only have a name, no path (of course).
My question: What is the easiest way to find a list of potentially missing files of my code in one go?
Please note that function depfun has been removed in recent versions of Matlab.
I'm having a lot of issues with Quandl in Matlab lately.
I tried adding +urlread2 to the Matlab search path but I got the message "you cannot add method folders or private folders to the matlab search path." I don't know why I'm getting this message since I'm supposed to add +urlread2 to the path to use Quandl.
Thoughts?
For class directories you shall only add the parent folder containing them to the path: MATLAB will then recognize the classes below automatically. This is what the message you get "means".
See for example how the genpath function is implemented.
Recently I've tried to use a custom performance function for NN in Matlab. What I did as an initial experiment, I took mse template and copy these files to my Matlab working directory. After that I renamed +mse folder and mse.m to mymse.m, leaving everything else(the code inside) unchanged. After that when I attempt to run NN tools with this new custom function(which is actually fully equal to the old one), Matlab randomly crashes.
And I don't mean exceptions. I mean Access Violation errors that kill Matlab instance.
When Matlab does not crash, it gives normal results.
Has anyone come across this problem?
Thank you.
you have to include the parent folder which +name folder is in.
Even if that parent folder is your current folder, it does not mean that it is included.
So, rigth click to the parent folder, and 'add to path'. This may be one of the reason that it crashes.
also, another thing that you have to keep in mind:
when trainin with custom performance functions, you may need to use train(net,x,t,nn7) instead of train(net,x,t) or you may get just zeros for output.
I am trying to run Kevin Murphy's Bayes Net Toolbox in Octave and encountering some problems. It doesn't help that I'm a novice at Bayesian networks, Matlab and Octave.
This toolbox was originally written for Matlab. There is a large test file called test_BNT.m which runs through all the functionality in the toolbox. Most of the error messages relate to the difference between & and && in Matlab and Octave. This is easy to fix. However, I've now come across a new problem and I don't know what to do about it.
For instance, the qmr1.m script creates an instance of the pearl_inf_engine class, sets some of the member member variables and passes the instance of the class to another function. Later on, the member variables are accessed again in a different script (parallel_protocol.m). But when this happens, the following message appears:
error: invalid index for class
error: evaluating argument list element number 1
It seems that from one script to another, it has forgotten that the class has any member variables and gives the invalid index message when you try to access them.
Is this a common error with an easy solution? Is something wrong with the path or working directory? Maybe someone else has already converted the BNT to octave and knows what to do?
Edit
I was able to get past this error message. The trick was to read the installation instructions (haha) and run addpath(genpathKPM(<BNT base directory)). genpathKPM.m is a script includes in BNT which adds all the required directories to the path.
After doing this, run test_BNT.m and change & to && and | to || at each line where it gives a warning. This will clear up most of the errors.
However, I'm still unable to run mpe1.m, mp2.m, mildew1.m and some others. The new error message I'm stuck on is:
error: invalid empty index list
error: called from:
error: C:\FullBNT-1.0.7\bnt\BNT\inference\static\#var_elim_inf_engine\find_mpe
.m at line 63, column 5
on this line of code:
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
If I can get all the scripts to work, I'll post an answer here with the steps I took to do it.
Edit 2
I was able to get past the problem in the previous edit. Replace
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
with
eval(['sCPT.T(', sargs, sprintf('%d',jj), ')=0;']);
The next problem is identical. Just replace num2str in the same way.
This file was apparently contributed by a user of BNT, and not written by the original author. Using eval kind of a hack, I think. A better fix would be to just rewrite the code so it doesn't use eval at all.
There is one more error in draw_graph.m, which was apparently also an outside contribution to the project. I just commented out the call to that function since I'm not interested in drawing graphs right now. After doing this, and continuing to fix shortcircuit operators, all of the tests in test_BNT.m will run.
Still, I won't create an answer for this until I can get draw_graph.m to run, too.
As a significant amount of time has passed, and the answer to the core problem was provided in the question, I will post it here so it will not stay listed as unanswered:
tl;dr: Change a few operators, solve the remaining bugs specified below, and everything works except the drawing of graphs.
Edit
I was able to get past this error message. The trick was to read the
installation instructions (haha) and run addpath(genpathKPM(<BNT base
directory)). genpathKPM.m is a script includes in BNT which adds
all the required directories to the path.
After doing this, run test_BNT.m and change & to && and | to
|| at each line where it gives a warning. This will clear up most of
the errors.
However, I'm still unable to run mpe1.m, mp2.m, mildew1.m and
some others. The new error message I'm stuck on is:
error: invalid empty index list
error: called from:
error: C:\FullBNT-1.0.7\bnt\BNT\inference\static\#var_elim_inf_engine\find_mpe
.m at line 63, column 5
on this line of code:
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
If I can get all the scripts to work, I'll post an answer here with
the steps I took to do it.
Edit 2
I was able to get past the problem in the previous edit. Replace
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']); with
eval(['sCPT.T(', sargs, sprintf('%d',jj), ')=0;']);
The next problem is identical. Just replace num2str in the same way.
This file was apparently contributed by a user of BNT, and not written
by the original author. Using eval kind of a hack, I think. A better
fix would be to just rewrite the code so it doesn't use eval at all.
There is one more error in draw_graph.m, which was apparently also
an outside contribution to the project. I just commented out the call
to that function since I'm not interested in drawing graphs right now.
After doing this, and continuing to fix shortcircuit operators, all of
the tests in test_BNT.m will run.
I have an issue with my ModX Evo site throwing this error:
Fatal error: Cannot redeclare insert_metka() (previously declared in /home/mysite/public_html/manager/includes/document.parser.class.inc.php(794) : eval()'d code:2) in /home/mysite/public_html/manager/includes/document.parser.class.inc.php(794) : eval()'d code on line 12'
I have searched and searched but cannot find where insert_metka() is declared. I even downloaded the entire site and ran a search to no avail. I also tried to updated the version to the latest, also to no avail.
Can anyone please tell me where to find this function?
Download a database dump and look for the this line in it. It seems that the fault one of the plugins, try disabling plugins until you find it. See ModX Evo: PHP error in document.parser.class.inc.php for more advices.
As you can see from your error-code, the function was declared in a snippet. This is because Modx has this way of caching snippets to speed up the performance. They make static files of your snippets wrapped as a function.
This may cause errors if the same function is called twice and you declared a function within it. I suspect that is what is going on here.
To solve this issue, simply wrap your entire function in function_exists like so:
if (!function_exists("insert_metka")) {
function insert_metka() {
// Stuff goes here
}
}
Sidenote: This is in addition to the answer given by Vasis. You should search your snippets, extras and plugins. It should be located somewhere in those files. It is not a function provided from the Modx core.