MATLAB在數學中的應用

MATLAB軟件有超強的計算功能,只要學好MATLAB軟件,可以解決所有高等數學問題,一起來學習吧!

M文件

MATLAB在數學中的應用

新建一個腳本文件,輸入命令。

<code>function Y=fun1(x)
Y=(x^3-2*x^2+x-6.3)/(x^2+0.05*x-3.14);/<code>

然後保存,M文件名必須與函數名一致。

在指令窗口運行以下指令:

<code>fun1(1)*fun1(2)+fun1(3)*fun1(3)/<code>

ans =-12.6023

作圖

MATLAB在數學中的應用

MATLAB在數學中的應用

<code>x=[0:1:10]; %產生X軸數據
y=x.^2-10*x+15; %產生Y軸數據
plot(x,y);
title('函數y=x.^2-10*x+15的圖像'); %添加標題
xlabel('x'); %添加橫座標
ylabel('y'); %添加縱座標
grid on; %繪製網格線/<code>
MATLAB在數學中的應用

極限

MATLAB在數學中的應用

<code>syms x a b;
f=x*(1+a/x)^x*sin(b/x);
limit(f,x,inf)/<code>

ans =b*exp(a)

<code>syms x;
y1=exp(x^3);
y2=cos(sqrt(x-sin(x)));
f=(y1-1)/(1-y2);
limit(f,x,0,'right')/<code>

ans =12

一元函數微分

MATLAB在數學中的應用

<code>syms x;
y=(x^x)^x;
yx=diff(y)/<code>

yx =log(x^x)*(x^x)^x + x*(x^x)^(x - 1)*(x*x^(x - 1) + x^x*log(x))

<code>syms x y
y=x^3*exp(5*x);
y1=diff(y);
y2=diff(y,x,5);
simplify(y1)/<code>

ans =x^2*exp(5*x)*(5*x + 3)

<code>simplify(y2)/<code>

ans =125*exp(5*x)*(25*x^3 + 75*x^2 + 60*x + 12)

不定積分

MATLAB在數學中的應用

<code>syms x
y=exp(5*x)*sin(4*x);
f=int(y,x)/<code>

f =-(exp(5*x)*(4*cos(4*x) - 5*sin(4*x)))/41

常微分方程

MATLAB在數學中的應用

<code>dsolve('Dy+2*x*y=x*exp(x^2)','x')/<code>

ans =exp(x^2)/4 + C7*exp(-x^2)

<code>dsolve('x*Dy+y-exp(x)=0','y(1)=2*E','x')/<code>

ans =(exp(1) + exp(x))/x

<code>dsolve('D2y-exp(2*y)*Dy=0','x')/<code>

ans =C11log((2*C11)/(exp(-4*C11*(C14 + x/2)) - 1))/2

級數

MATLAB在數學中的應用

<code>syms n;
symsum(1/2^n,n,1,inf)/<code>

ans =1

得到結果為1,說明該級數收斂。

<code>syms n;
symsum(1/(n*(n+1)),n,1,inf)/<code>

ans =1

得到結果為1,說明該級數收斂。

<code>syms n x;
symsum(x^n/(n*2^n),n,1,inf)/<code>

ans =piecewise([x == 2, Inf], [abs(x) <= 2 & x ~= 2, -log(1 - x/2)])

<code>syms n x;
symsum(n*x^n,n,1,inf)/<code>

ans =piecewise([abs(x) < 1, x/(x - 1)^2])

多元函數微積分

MATLAB在數學中的應用

<code>a=-4:0.2:4b=-5:0.2:5;[x,y]=meshgrid(a,b);z=exp(-(x.^2+y.^2)/5)/(3*sqrt(4*pi));plot3(x,y,z)/<code>
MATLAB在數學中的應用

MATLAB在數學中的應用

<code>[xy]=meshgrid(-4:0.2:4);
z=x.^3+y.^3-6.*x-6.*y;
figure(1),
mesh(x,y,z)
figure(2),[c,h]=contour(x,y,z);
clabel(c,h)
figure(3)
hl=[-28 -16 -8 0 6 18 26];
cl=contour(z,hl);
clabel(cl)
figure(4),
contour(z)
figure(5),
contour3(z,10)/<code>
MATLAB在數學中的應用

MATLAB在數學中的應用

MATLAB在數學中的應用

MATLAB在數學中的應用

MATLAB在數學中的應用

以上就是今天推送的文章

後臺私信:數據分析入門

即可獲取一份數據分析入門資料


分享到:


相關文章: