suppressing printing every assignment
by adding a semicolon at the end of your statement it will suppress the intermediate result. In your case: function result = stuff() result = 0; for i=0:10, j += i; end end will do the trick.
by adding a semicolon at the end of your statement it will suppress the intermediate result. In your case: function result = stuff() result = 0; for i=0:10, j += i; end end will do the trick.
There are four ways how Matlab code gets sped up: JIT: compiling at runtime helps with loops but seems to speed up (or at least interact with) other parts of the code as well, according to my anecdotal observations. Implementing functions in C/C++: There’s a bunch of Matlab/Octave functions that are implemented in Matlab/Octave. At … Read more
I think the sortrows function is what you’re looking for. >> sortrows(data,1) ans = -1 4 1 3 5 7
What you’re doing in the first example in the second block you’ve missed out a step haven’t you? I am assuming you concatenated X with a vector of ones. temp=X(:,2) * temp The last example will work but can be vectorized even more to be more simple and efficient. I’ve assumed you only have 1 … Read more
to clear the command window type: clc
arrayfun works well for this: arrayfun(@(x) 1/(1+e^(-x)), [0, 1; 2, 3]) Output: ans = 0.50000 0.73106 0.88080 0.95257 This basically runs function 1/(1+e^(-x)) on each element of the matrix/vector.
Vectorized operations like .^ are exactly the kind of thing that Octave is good at because they’re actually entirely implemented in specialized C code. Somewhere in the code that is compiled when Octave is built, there is a C function that computes .^ for a double and an array of doubles – that’s what you’re really timing … Read more
Sublime 2 can be configured to associate certain file extensions to certain syntax highlighting schemes. See this answer for exactly how to do it https://stackoverflow.com/a/8014142/694184
You will have to look inside the code of fmincg because it is not part of Octave. After some search I found that it’s a function file provided by the Machine Learning class of Coursera as part of the homework. Read the comments and answers on this question for a discussion about the algorithms.
You could use the following test to differentiate Octave from MATLAB: isOctave = exist(‘OCTAVE_VERSION’, ‘builtin’) ~= 0;