Hi, im trying to understand why when im using sparse matrix vs full matrix for solving linear system, i got different values only at the edges.
im using the following code:
l = [12; 6 * ones(98,1); 0];
d = [6; 24*ones(98,1); 6];
u = [0; 6*ones(98,1); 12];
c = spdiags([ l,d,u ],[-1 0 1],100,100);
b = randn(1, 100);
s1 = b/c;
s2 = mldivide(full(c),b')';
figure;plot(s1);hold on;plot(s2);
The sparse part is from spline.m source code.

 採用された回答

Matt J
Matt J 2020 年 11 月 22 日
編集済み: Matt J 2020 年 11 月 22 日

0 投票

Because you forgot to transpose c,
s2 = mldivide(full(c.'),b.').';

1 件のコメント

Chen Dadon
Chen Dadon 2020 年 11 月 22 日
Well thank you for the quick response! It saves me a lot of time!

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

その他の回答 (0 件)

タグ

質問済み:

2020 年 11 月 22 日

コメント済み:

2020 年 11 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by