怎么用MATLAB??这几个题怎么做
5.在同一个坐标下画出y1=1+x,y2=1+x+x2/2,y3=cosx,y4=ex并标示;6.求函数f(x)=x^3-2x+5在x=2附近的零点,并画出函数图像;7....
5.在同一个坐标下画出
y1=1+x,
y2=1+x+x2/2,
y3=cosx,
y4=ex
并标示;
6.求函数f(x)=x^3-2x+5在x=2附近的零点, 并画出函数图像;
7.求矩阵
的行列式值,逆和特征根;
8.求微分方程-6+5y=的通解; 展开
y1=1+x,
y2=1+x+x2/2,
y3=cosx,
y4=ex
并标示;
6.求函数f(x)=x^3-2x+5在x=2附近的零点, 并画出函数图像;
7.求矩阵
的行列式值,逆和特征根;
8.求微分方程-6+5y=的通解; 展开
1个回答
展开全部
clear all; clc; clf;
% plot various functions
clear all
x = -3:.1:3;
y1 = 1+x;
y2 = 1+x+x.^2/2;
y3 = cos(x);
y4 = exp(x);
plot(x,y1,x,y2,x,y3,x,y4); grid on;
legend ('1+x','1+x+x.^2/2','cos(x)','exp(x)','location','northwest');
% newton's method
clear all;
x0 = 2.0;
% f(x)
f = @(x) x.^3-2*x+5;
% f'(x)
fp = @(x) 3*x.^2-2;
t = 1E-7;
ep = 1E-14;
max= 200;
for i = 1 : max
y = f(x0);
yp = fp(x0);
if (abs(yp < ep))
break;
end
x1 = x0 - y/yp;
if (abs(x1-x0)/abs(x1) < t)
fprintf('\nrun %d ----- x = %.4f\n', i, x1);
break;
end
x0 = x1;
end
% solve the general equation
syms y(x)
eqn = diff(y,x) == 5/6*y;
eqnp = dsolve( eqn );
pretty (eqn)
pretty (eqnp)
% matrix algebra
clear all;
A = [ 1 2 3; 2 3 4; 1 2 5];
dtm = det(A);
imt = inv(A);
[v,D] = eig(A);
disp('Matrix A = ');
disp(A);
fprintf('\nthe determinant of A is %.4f\n', dtm);
disp('Matrix inverse A = ');
disp(imt);
disp('the eigenvalues on the diagonal of a diagonal matrix ');
disp(D);
The ouput on the IDE should be
The graph should look like
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询