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.
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
An easy inline way to do this is: b = [ones(size(b, 1), 1) b];