I want to create a tridiagonal matrix in scilab/matlab such that it uses for loops. I dont know how to create the matrix but here is what i have started
for i=2:n
a_{1,1}=2
a_{i,i}=2
a_{i,i-1}=1
a_{i,i+1}=1
end
Thats the components of the matrix and if possible the other components which are zero will not be stored for efficient memory usage.
MATLAB code:
I don't know how to define the matrix without storing the zeros, but I know it's called sparse matrix. These links might be helpful: