[大學]Matlab算線性代數(急

[大學]Matlab算線性代數(急

god9595995 於 星期五 十月 01, 2010 6:17 pm


產生矩陣
A=floor(10*rand(6))
產生向量
b=floor(20*rand(6,1))-10

Ax=b 有唯一解
用\找結果
用Matlab算出列簡梯形形式 (reduced row-echelon form)
U of [A b]
How does the last column of U compare with the solotion x?
為啥他們會一樣?

To compare the two ,compute the difference U (:,7) -x or examine both using format long.
--------------------------------------------------------------
幫幫我吧 matlab有些語法不太懂 我怕誤解題目的意思 所以把原文打出來了:D


god9595995
初學者
初學者
 
文章: 1
註冊時間: 2010-10-01

grove888 於 星期五 十二月 17, 2010 3:25 pm


clc
clear all
tic
x=floor(10*rand(6))
b=floor(20*rand(6,1))-10
a=inv(x)*b;
a1=a(1)
a2=a(2)
a3=a(3)
a4=a(4)
a5=a(5)
a6=a(6)
toc

grove888
初學者
初學者
 
文章: 31
註冊時間: 2010-08-28

lskuo 於 星期六 十二月 18, 2010 8:57 pm


如果要求解 Ax=b

Matlab 有建議要用

x = A\b;

這樣會比用inv(A)找反矩陣的方法快. 矩陣小的時候看不出來, 但你試試
N=2000;
A=rand(N,N);
b=rand(N,1);

x = A\b;

x = inv(A)*b;

就可以知道 "\"的威力.

lskuo
專 家
專 家
 
文章: 278
註冊時間: 2010-11-10

grove888 於 星期一 十二月 20, 2010 12:32 pm


多謝指教,我再試看看。

grove888
初學者
初學者
 
文章: 31
註冊時間: 2010-08-28




大學以上數學問題