Hello, in the provide code there is A(r+1, r+1:r+2) = [0 1]; I wonder why would we want to assign A(r+1, r+1) = 0 instead of just do A(r+1, r+2) = [1]; ? This also applies for other assigning statement, since the matrix A is initialized to be all zero sparse, is there a particular reason to assign 0 for some values? i.e. to prevent inaccurate numerical calculation? Thank you.
There is no issue with inaccurate numerical calculation.
This is just assignment. If you do not include the assignment to 0,
it will be done automatically by matlab.
However, for the look of the code, it is nicer to have it the way I give it, so that you always explicitly include the diagonal element.
It somehow guides our eyes. At least, this is what I think.
1 Like