Solving large system of linear equations

2 ビュー (過去 30 日間)
Saurabh Madankar
Saurabh Madankar 2021 年 11 月 16 日
コメント済み: Saurabh Madankar 2021 年 11 月 16 日
How to solve a large system of linear equations in MATLAB? In particular I have 31 equations and 31 unknowns and I can write these equations recursively. Say I have equations of the type c(n-1)-c(n)+c(n+1)= 0, n varying from 2 to 32 where I know the values of c(2) and c(32).
  2 件のコメント
Matt J
Matt J 2021 年 11 月 16 日
Are you sure you don't mean, you know the first and the last point, c(1) and c(32)? You're trying to solve for c(2)..c(31) correct?
Saurabh Madankar
Saurabh Madankar 2021 年 11 月 16 日
That is the case but I need to calculate c(0) and c(32) as well, but because of MATLAB indexing, it means I need to calculate c(1) and c(33) with c(2) and c(32) being known.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2021 年 11 月 16 日
編集済み: Matt J 2021 年 11 月 16 日
n=32;
c(1,1)=5; c(n,1)=10; %Example data
T=toeplitz([-1,zeros(1,n-3)], [-1,1,-1, zeros(1,n-3)]);
A=T;
A(:,[1,n])=[];
b=T(:,[1,n])*[c(1);c(n)];
c(2:n-1)=A\b
c = 32×1
5 -10 -5 5 10 5 -5 -10 -5 5
  1 件のコメント
Saurabh Madankar
Saurabh Madankar 2021 年 11 月 16 日
Thanks, I have got the idea now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by