alias matlab '/usr/local/bin/matlab -nojvm -nosplash'
for pre-2009a versions, and
alias matlab '/usr/local/bin/matlab -nodesktop -nosplash'
for the newer ones. Nosplash prevents the advertisement screen
on startup.
format short; y = -10:12 ; z = y.^10to see what happens
for k = 1:n
C(1:n,k) = v(1:n);
end
makes n calls for memory allocation from operating system, and it requires
copying over the part of C built up so far to the newly allocated
space each time. Instead use
C = zeros(n,n);
for k = 1:n
C(1:n,k) = v(1:n);
end
Better yet, use: C = v(1:n)*ones(1,n);
x = 1:nsets up a vector of length n, but is it a row vector or column vector? In the first case,
y = A(1:n,1:n)*xgives an error message, while in the second it is valid. Handle this by converting it into a column vector: x = x(:). This makes x a column vector whether it is a row or column vector to begin with. It also converts a 2D array into a 1D array. Also see the reshape() function.