You are on page 1of 13

Eval: ly gi tr s

Quad(@(x),1,2): tch phn s


fminbnd(@(x)x^2,-1,1)
Fzero(@f,[])
Rand: ma trn ngu nhin
Rref(c) :
Function xdot =example(t,x)
Xdot(1) = x(2);
Xdot(2)=(1/5)*sin(t)-4*x(1) 7*x(2);
G ra ngoi:
[t,x] = ode45(example,[0,6],[3,9]);
Plot(t,x)
Int( tch phn s)
Diff: o hm
Ones: ma trn 1
Eye: ma trn n v
k=find(b>.5)
b(k)=.5
A: chuyn v ma trn A
Nhn 2 m trn nu c . l nhn cc phn t vi nhau. K chm l nhn 2 ma trn.
Bnh phng tng t
Inv(a): ma trn nghc o
Diag: ma trn ng cho
Zeros: ma trn 0
[t,x]=ode23(@(t,x) t*x/(1+x)^2,[0,2],3)
Rats: hin th dng phn s
Roots: giair phuowng trinh bac cao

Tnh tch phn dng quad hay double kt qu


Ch subs
Tch phn, o hm, tnh do hm theo x hay theo y
Ma trn; bit thit lp ma trn, n v, cho, ma trn 0, ma trn con. Ri ghp ni
ma trn, cc cch bin i ma trn, cng tr ma trn, gii h ph ng trnh i s
tuyn tnh dng ma trn,
- phng trnh vi phn: ode23, ode45, ode..
Cch s dng grid, quiver( v tip tuyn), gi theo symbolic,
Lp trnh trong matlab: vng lp, iu kin, vit chng trnh c vo gi tr bin,
x l v a vo kt qu theo yu cu bi ton
V tip tuyn dng quiver(x,y,u,v)
Tnh x= 0.2: 0.2:.8
Y = subs
U=1 ;v= subs(diff(y,x),xx)
C sn xx, yy th ta ch cn lm t bc 2
Bi 2. Kho st dng for
To ma trn 1 2 3;
GI VI PHN c trg vec t b
Phn bit figure vi subplot
1 bi ton k yu cu phg php no th dng ng phg php . n tp tt c bi tp
cho. Lp trnh no cng c
Bi 1:
syms x t
y1=atan(x)./(1+x.^2)
y2=(1+sin(t))./((1+cos(t)).^2)

figure

subplot(1,2,1)
hold on
ezplot(y1,[0 2])
xx=[0.2:0.2:0.8]
yy=subs(y1,xx)
u=[1,1,1,1];
v=subs(diff(y1,x),xx)
quiver(xx,yy,u,v)
hold off

subplot(1,2,2)
hold on
ezplot(y2,[0 2])
tt=[0.2:0.2:0.8]
yy=subs(y2,tt)
u=[1,1,1,1];
v=subs(diff(y2,t),tt)
quiver(tt,yy,u,v)
hold off
3.19
>> ezplot(f,[0,1])
>> grid
>>xmin = fminbnd(char(f),0,1)

xmin =

0.3820

>> ymin =subs(f,x,xmin)

ymin =

6.2065
df =diff(f)

df =

exp(x)/(x*(x - 1)^2) - exp(x)/(x*(x - 1)) + exp(x)/(x^2*(x - 1))

>> nghiem =solve('df=0')

nghiem =

>> nghiem =solve(df)

nghiem =

5^(1/2)/2 + 3/2
3/2 - 5^(1/2)/2

>> x1 =eval(nghiem(1))

x1 =

2.6180

>> x2=eval(nghiem(2))

x2 =

0.3820

>>a = subs(f,x,x2)

a=

6.2065

>> explot(exp(x),0,1)
??? Undefined function or method
'explot' for input arguments of type
'sym'.

>> ezplot(exp(x),0,1)
>> grid
>> hold on
>> ezplot(a*x*(1-x),0,1)
>>
Bai 20

f = exp(-x^2)*(x+sqrt(x))

f=

(x + x^(1/2))/exp(x^2)

>> ezplot(f,.5,.7)
??? Error using ==> figure
Single input must be an existing figure
handle or a scalar integer from 1 to
2147483646

Error in ==> ezplot>determineAxes at


550
figure(fig);

Error in ==> ezplot>ezplot1 at 444


cax = determineAxes(fig);

Error in ==> ezplot at 144


[hp,cax] =
ezplot1(cax,f{1},vars,labels,args{:});

Error in ==> sym.ezplot at 69


h = ezplot(char(f),varargin{:});

>> ezplot(f)

>> ezplot(f)
>> xmin =fminbnd(char(f),0.5,0.7)

xmin =

0.6999

>> xmin =fminbnd(char(-f),.5,.7)

xmin =

0.5992

>> xman =fminbnd(char(-f),.5,.7)

xman =

0.5992
ymax =subs(f,x,xman)

ymax =

0.9590
4.15
a=[1 2 3;2 -3 2;3 1 -1]

a=

2 -3

1 -1

>> b =[6;14;-2]

b=

6
14
-2

>> c = a\b

c=

1.0000
-2.0000
3.0000

>> rref(c)

ans =

1
0

>> x = a\b

x=

1.0000
-2.0000
3.0000

>> c =[a,b]

c=

2 -3
3

2 14

1 -1 -2

>> rref(c)

ans =

0 -2

>>4.16

a=

2 -3

>> b = [4;-4]

b=

4
-4

>> a/b
??? Error using ==> mrdivide
Matrix dimensions must agree.

>> a\b

ans =

0
1.5385
0.3077

>> a/b
??? Error using ==> mrdivide
Matrix dimensions must agree.

>> a\b

ans =

0
1.5385
0.3077

>> b=[-4;4]

b=

-4
4

>> a\b

ans =

0
-1.5385
-0.3077
rref([a,b])

ans =

Columns 1 through 3

1.0000

0 1.8571

0 1.0000 0.5714

Column 4

-0.5714
-1.7143
5.1
function xdot = viphan2(t,x)
xdot = 1 -2*x*t

end

ode23('viphan2',[0,3],1)
4.22
c. so snh ta tnh hsdk = norm(a) nhn vi ma trn nghch o ca a.
hs b hn tt hn
5.6
Y=
T0=fminbnd(@(t)y...,0,1)
T1 = fminbnd(,1,2)
T = t1 t0 tm ra t => f
5.7 khng ph hp. k ra

You might also like