Amaliy qism;
Ikki o’lchovli fazoda grafik usulda tasvirlash.
1.function m1()
x=-150:0.1:150;
fun=@(x,k)k*sin(x);
for i=1:size(x,2)
y(i)=fun(x(i),i);
end
plot(x,y);
%axis([-100 50 -50 150]);
grid on;
end
2.function m2()
x=-15:0.1:15;
fun=@(x)x*sin(3*x)*sin(2*x);
for i=1:size(x,2)
y(i)=fun(x(i));
y1(i)=-fun(x(i));
y2(i)=fun(-x(i));
end
plot(x,y);
%axis([-100 50 -50 150]);
grid on;
end
3.function m3()
x=-15:0.1:15;
plot(x,sin(x).^3)
gtext('Function sin(x).^3')
end
4.function m4()
Z=[-3+3*i,-2-3*i,1+2*i,4+i];
plot(Z)
xlabel('X oqi')
ylabel('Y oqi')
end
5.function m5()
x=0:0.1:4;
y=cos(x.^2).*exp(-x);
stem(x,y),
end
6.function m6
x=0:1:100;
loglog(x,2000./exp(x),'--ob');
grid on
end
7.function m 7()
x=logspace(-1,3);
loglog(x,exp(x)./x)
grid on
end
8.function m8()
x=-6:.1:6;
plot(x,sin(x),x,sin(x).^2,x,sin(x).^4);
end
9.function m9()
x=(-10:0.1:10);
y=cos(2*x);
plot(x,y)
end
10.function m10()
V=[1 2 8 6 3 4 7];
bar(V)
end
Uch o’lchovli fazoda grafik usulda tasvirlash.
1. function m1()
x=[-1:0.1:1];
y=[-1:0.1:1];
[x,y]=meshgrid(x,y);
for t=1:0.01:10
for i=1:size(x,2)
for j=1:size(y,2)
z(i,j)=t*exp(y(i,j))*sin(x(i,j)^5);
end
end
surf(x,y,z);
axis([-1 1 -1 1 -10 30]);
drawnow;end
2. function m2()
x=[-1:0.1:1];
y=[-1:0.1:1];
[x,y]=meshgrid(x,y);
for t=1:0.01:10
for i=1:size(x,2)
for j=1:size(y,2)
z(i,j)=t*cos(y(i,j))*exp(x(i,j)^5);
end
end
surf(x,y,z);
axis([-1 1 -1 1 -10 30]);
drawnow;
end
3.function m3()
[X,Y]=meshgrid(-5:0.1:5);
Z=X.*sin(X+Y);
meshc(X,Y,Z)end
4.function m4()
[X,Y]=meshgrid(1:0.1:5);
Z=X.*tan(X+Y);
meshc(X,Y,Z)
surf(x,y,z);
axis([-1 1 -1 1 -10 30]);
drawnow;
5. function m5()
f=@(x,t)t*x*cos(x);
x=-10:0.01:10;
n=size(x,2);
for t=1:0.01:10
for i=1:n
y(i)=f(x(i),t);
end
plot(x,y);
grid on
axis([-10 10 -10 10]);
drawnow
endm6
6.function m6()
x=-5:0.1:5;
y1=cos(x);
y2=cos(x).^2
y3=cos(x).^5
plot(x,y1, x, y2 , x, y3);
legend( ' function 1', ' function 2', ' function 3');
axis([-5 5 -2 2 ])
grid on;
end
7.function m7()
f=@(x,t)t*x*cos(x);
x=-10:0.01:10;
n=size(x,2);
for t=1:0.01:10
for i=1:n
y(i)=f(x(i),t);
end
plot(x,y);
grid on
axis([-10 10 -10 10]);
drawnowend
8.function m8()
x=-10:0.1:10;
y1=tan(x);
y2=tan(x).^2
plot(x,y1, x, y2 );
legend( ' function 1', ' function 2');
axis([-10 10 -2 2 ])
grid on;
end
9.function m9()
x=-10:0.01:10;
n=size(x,2);
fun=@(x)cot(x);
for i=1:n
y(i)=fun(x(i));
end
plot(x,y);
axis([-10 10 -2 2]);
grid on;
axis([-10 10 -10 10]);
drawnow
end
9-Mavzu: Matlab dasturida tenglamalarning haqiqiy ildizini taqribiy hisoblash.
1.function m1()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x) x^3-9*x^2+31*x+37;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=-1
b=0
-0.921670
2.function m2()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)ln(x)-x+13;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=15
b=16
15.7573
3.function m3()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x) x^3+3*x-1;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=0
b=1
0.3221853
4.function m4()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x-cos(x);
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=0
b=1
0.7390851
5.function m5()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x^3-3*x^2+7*x+3;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=0
b=1
-0.3646556
6.function m6()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x*2^x-1;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=0
b=1
0.6411858
7.function m7()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x^3-2*x-5;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=2
b=3
2.094551
8.function m8()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)sqrt(x^2+1)-1/x;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=1/2
b=1
0.7861513
9.function m9()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x^3-6*x^2+16*x-14;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=1
b=2
1.526534
10.function m10()
a=input('a=');
b=input('b=');
e=0.00000001;
fun=@(x)x+lg(x)-0.5;
if fun(a)*fun(b)<0
while true
n=(a+b)/2;
if fun(a)*fun(n)<0
b=n;
else
a=n;
end
if abs(b-a)
break
end
end
fprintf('%7f\n',a);
else
fprintf('yechimiyoq %f\n',' ');
end
end
NATIJA:
a=1/2
b=1
0.6723832
10-Mavzu: Matlab dasturida integrallarni taqribiy hisoblash.
Nazariy qism:
Integrallarni taqribiy hisoblashning tortburchak, trapetsiya va simpson usullari mavjud.
Integral sintaksisi
q = integral2(fun,xmin,xmax,ymin,ymax)
q = integral2(fun,xmin,xmax,ymin,ymax,Name,Value)
q = integral2(fun,xmin,xmax,ymin,ymax) approximates the integral of the function z = fun(x,y) over the planar region xmin ≤ x ≤ xmax and ymin(x) ≤ y ≤ ymax(x).
example
q = integral2(fun,xmin,xmax,ymin,ymax,Name,Value) specifies additional options with one or more Name,Value pair arguments.
q = integral(fun,xmin,xmax)example
q = integral(fun,xmin,xmax,Name,Value)example
Description
example
q = integral(fun,xmin,xmax) approximates the integral of function fun from xmin to xmax using global adaptive quadrature and default error tolerances.
example
q = integral(fun,xmin,xmax,Name,Value) specifies additional options with one or more Name,Value pair arguments.
Integrallartni hisoblashni simpson trapetsiya va tortburchaki usullari mavjud. Trapetsiya usulining umumiy fo`rmulasi quiyidagicha
S(n)=n*(f(x[n])+f(x[n-1]))/2
Bu yerda x[i]=a+i*h
H esa uning qadami bolib h=(b-a)/n ifoda orqali hisoblanadi.
integral
Numerically evaluate integralexpand all in page
Syntax
q = integral(fun,xmin,xmax)example
q = integral(fun,xmin,xmax,Name,Value)example
Description
example
q = integral(fun,xmin,xmax) approximates the integral of function fun from xmin to xmax using global adaptive quadrature and default error tolerances.
Specify 'ArrayValued',true to evaluate the integral of an array-valued or vector-valued function. Create the anonymous vector-valued function. Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' ').
0>0>0>0>0>0>0>0>0>0>
Do'stlaringiz bilan baham: |