MATLAB Answers

Solving Ax=b with both unknowns in A and b

3 views (last 30 days)
Hai Nguyen
Hai Nguyen on 13 Aug 2019
Commented: Torsten on 15 Aug 2019
Anyone please help me with this problem. I only know some basic when it comes to matlab and having lots of difficulties trying to code this matrix problem Ax=b that have unknown in both A and b.
The linear system obtained in the form of
where are constants, m is time step, , (initial and boundary values - W at t=0 and W at the last node and outside =0)
How to create the tridiagonal matrix A and vector b in matalb please? I tried to search similiar codes but only found the equations where A and b are known...in this case A and b have symbolic arguments in power form and they are related to the solution

  6 Comments

Show 3 older comments
Hai Nguyen
Hai Nguyen on 13 Aug 2019
Mr Roberson, could you please elaborate a bit more?
Walter Roberson
Walter Roberson on 13 Aug 2019
diag(vector1, -1) + diag(vector2) + diag(vector3, 1)
builds a tridiagonal matrix.
Walter Roberson
Walter Roberson on 13 Aug 2019
All of the j=i-1 entries are constructed the same way and they all fall along the diagonal just to the left of the major diagonal

Sign in to comment.

Accepted Answer

Torsten
Torsten on 13 Aug 2019
Edited: Torsten on 13 Aug 2019
Now if W_{0}^{m} and W_{N+1}^{m} are 0 (I think you meant W_{0}^{m} instead of W_{N}^{m}), you have a system of N equations in W_{1}^{m},...,W_{N}^{m}.
You can use Walter's suggestion to solve for W_{1}^{m+1},...,W_{N}^{m+1}.
I don't understand why you write that there are unknowns in A and b. The W's in A and b are the W's from the last time step (m) and thus known. The unkowns are W_{1}^{m+1},...,W_{N}^{m+1}.

  13 Comments

Torsten
Torsten on 15 Aug 2019
Take (A-5) and (A-7) to calculate W_{0}^{m}.
This is the missing boundary value at x=0.
In the last program I posted, you just have to replace b(1) by this value.
Hai Nguyen
Hai Nguyen on 15 Aug 2019
Thank you Sir for your kindness and patience. If I would like to reduce the time step from 1 to 0.01, which lines of the above program I need to change?
Torsten
Torsten on 15 Aug 2019
From your equations, you have to change C1 and C2 accordingly, don't you ?
I wonder where the (delta_x)^2 in the denominator of C1 has gone ...

Sign in to comment.

More Answers (0)

Sign in to answer this question.