How to make a matrix using a column sweep?

2 views (last 30 days)
M Faisal Riyad
M Faisal Riyad on 20 Nov 2015
Edited: dpb on 20 Nov 2015
I am a new user in Matlab. I derived a set of following equations:
A(i,j)*alpha/dt - A(i,j+1)*gamma/dt - A(i,j-1)*delta/dt = A(i-1,j)*beta/dt
I declared a rectangular matrix of A with initial zero values for all the row and columns. Declared all the coefficients and now i want to set all the values for all nodes in the matrix except the boundary rows and columns i.e. 1st and last column and row. My code is not working. Could anyone help me in setting up the matrix.
%for the inner nodes
for i = 2:(N-1)
for j = 2:(M-1)
A(i,j) = alpha/dt
A(i-1,j) = beta/dt
A(i,j+1) = gamma/dt
A(i,j-1) = delta/dt
end
end

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!