Octave 解线性方程组

abellong posted @ 2012年4月14日 01:00 in 数学 , 5528 阅读

$Octave$ 解线性方程组的能力还没有 $matlab$ 强. 对于方程 \(A\times X=B\), $Octave$ 要求 \(A\) 是方阵, \(B\) 是向量; 而 matlab 并没有这些要求, 假设 \(A\) 是 \(m\times n\), \(B\) 是 \(m\times k\), 则可以用 $matlab$ 算出 \(X\), 它是 \(n\times k\) 的.

$Octave$ 解方程组的式子为 \(A\backslash B\). 下面提供两个例子

octave:1> # 
octave:1> A=[0,2,0,1;2,2,3,2;4,-3,0,1.;6,1,-6,-5]

A =

   0   2   0   1
   2   2   3   2
   4  -3   0   1
   6   1  -6  -5

octave:2> B=[0;-2;-7;6]

B =

   0
  -2
  -7
   6


octave:3> A\B

ans =

  -0.50000
   1.00000
   0.33333
  -2.00000

先生成一个随机方阵 $C$ 和随机向量 $D$ 并解方程 $$C\times x=D$$

octave:1> C=rand(5,5)
C =

   0.847817   0.122730   0.298340   0.652850   0.985631
   0.880412   0.618896   0.590534   0.485949   0.763285
   0.358464   0.384306   0.469336   0.909417   0.554835
   0.306760   0.672447   0.043989   0.371049   0.692044
   0.314791   0.410965   0.487560   0.485444   0.892830

octave:2> D=rand(5,1)
D =

   0.50708
   0.99851
   0.31515
   0.70781
   0.66774

octave:3> C\D
ans =

   0.32657
   0.77660
   0.32264
  -0.50477
   0.37354

 

Avatar_small
professional cleanin 说:
2021年9月07日 17:49

No matter the reason, there isn't any doubt how the maid costume will be as popular because ever. Certainly many of the appeal towards the costume originates from the males who desire to see women wear it instead of from ladies themselves attempting to portray the maid. It's been a significant fantasy associated with men all over the world for several years.

Avatar_small
Bihar Board 5th Clas 说:
2022年9月06日 18:20

Bihar Board Model Paper 2023 Class 5 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. Bihar Board 5th Class Model Paper New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter