Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101971733
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-09 17:23:00

原文:

Octave是GNU的一个项目,作为最好的Matlab免费替代品之一(另一个是Scilab),我们可以用它做很多事情…

函数积分:
Octave supports three different algorithms for computing the integral of a function f over the interval from a to b. These are

quad
Numerical integration based on Gaussian quadrature.
quadl
Numerical integration using an adaptive Lobatto rule.
trapz
Numerical integration using the trapezodial method.

Sample:
对函数
f(x) = x * sin (1/x) * sqrt (abs (1 - x))

function y = f (x)
y = x .* sin (1 ./ x) .* sqrt (abs (1 - x));
endfunction
[v, ier, nfun, err] = quad (”f”, 0, 3)
=> 1.9819
=> 1
=> 5061
=> 1.1522e-07
使用fplot(”f”, [0, 3])可以看到图形

解非线性方程:
-2x^2 + 3xy   + 4 sin(y) = 6
3x^2 - 2xy^2 + 3 cos(x) = -4

function y = f (x)
y(1) = -2*x(1)^2 + 3*x(1)*x(2)   + 4*sin(x(2)) - 6;
y(2) =  3*x(1)^2 - 2*x(1)*x(2)^2 + 3*cos(x(1)) + 4;
endfunction

[x, info] = fsolve (”f”, [1; 2])
x =

0.57983
2.54621

info = 1

阅读(2197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~