Solving Ax=b with both unknowns in A and b

2 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-8-13
diag(vector1, -1) + diag(vector2) + diag(vector3, 1)
builds a tridiagonal matrix.
Walter Roberson
Walter Roberson 2019-8-13
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

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2019-8-13
编辑:Torsten 2019-8-13
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 个评论
Hai Nguyen
Hai Nguyen 2019-8-15
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 2019-8-15
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 ...

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by