Pages

Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts

Thursday, May 6, 2010

matlab 迭代求解

x=fsolve(fun,x0)求解fun(x)=0的解,x0是初值,fun是函数,x是解
因为fsolve使用迭代法求解方程的,所以要有个迭代的初值x0。
比如解方程组
x(1).^2+x(2).^2=1
x(1)=2*x(2)
可以写成
f=@(x)([x(1).^2+x(2).^2-1;x(1)-2*x(2)])
x=fsolve(f,[1 1])
这里[1 1]就是初值。 

Friday, February 5, 2010

matlab 分段函数

x=[-3:0.1:4];
y=(x+2).*(x<0)+(-x+3).*(x>=0);
plot(x,y)

Monday, January 25, 2010

ezplot 线形 坐标轴的笨办法……

h=ezplot('sin(x)')

set(h,'Color','red')

----------------------------------------------------

plot([a,b],[c,d],’-’)

a = beginning of x axis;

b = ending of x axis;

c= beginning of y ;

d= y ending;a=0;