实验六
2_1
clear;
x=linspace(0,2*pi,101);
y1=x.^2;
y2=cos(2.*x);
y3=y1.*y2;
plot(x,y1,'b-',x,y2,'r:',x,y3,'g-.'); %y1蓝色实线,y2红色虚线,y3绿色点画线
2_2
subplot(2,2,1);
%分四个子图(先画2行2列第1块) plot(x,y1);
subplot(2,2,2);
plot(x,y2),
subplot(2,2,3);
plot(x,y3);
2_3 ()
subplot(3,4,1); %y1的四种图形bar(x,y1);
subplot(3,4,2);
stairs(x,y1),
subplot(3,4,3);
stem(x,y1);
subplot(3,4,4);
fill(x,y1,'b');
subplot(3,4,5); %y2
bar(x,y2); %条形图subplot(3,4,6);
stairs(x,y2), %阶梯图subplot(3,4,7);
stem(x,y2); %杆图subplot(3,4,8);
fill(x,y2,'b'); %填充图,注意必须加填充颜色
subplot(3,4,9); %y3
bar(x,y3);
subplot(3,4,10);
stairs(x,y3),
subplot(3,4,11);
stem(x,y3);
subplot(3,4,12);
fill(x,y3,'b');
3
clear;
x=-5:0.1:5;
if x<=0
y=(x+sqrt(pi)/exp(2));
else
y=0.5.*log(x+sqrt(1+x.^2));
end
plot(x,y);
4
M文件,假设文件名为Untitled6 a=input('a=');
b=input('b='); %b单位为pi/4 b=b*pi/4;
n=input('n=');
q=linspace(-2*pi,2*pi,100);
p=a*sin(b+n*q);
plot(q,p);
hold on; %保持图形
命令窗口调用情况
>> Untitled6
a=1
b=1
n=1
>> Untitled6
a=2
b=2
n=2
5.程序:
x=linspace(-5,5,21);
y=linspace(0,10,31);
[x,y]=meshgrid(x,y);
z=cos(x).*cos(y).*exp(-0.25*sqrt(x.^2+y.^2)); subplot(1,2,1);
title('surf(x,y,z)');
surf(x,y,z);
subplot(1,2,2);
title('surfc(x,y,z)');
surfc(x,y,z);
实验七
701
clear all
hf=figure('Color',[1,0,0],'KeyPressFcn','disp(''Left Button Pressed'')');
702
clear all
x=linspace(-2*pi,2*pi,500);
y=x.^2.*exp(2*x);
h=plot(x,y);
set(h,'Color','r','LineStyle',':','LineWidth',5)
title('下图是y=x^2e^{2x}曲线的图像');
703
clear all
a=linspace(-2*pi,2*pi,40);
b=linspace(-2*pi,2*pi,40);
[x,t]=meshgrid(a,b);
v=10*exp(-0.01*x).*sin(2000*pi*t-0.2*x+pi);
axes('view',[-37.5,30]);
h=surface(x,t,v,'FaceColor','w','EdgeColor','flat');
grid on;
title('函数图像如下');
set(h,'FaceColor','flat');
705
%实验七底层绘图操作
clear all;
[x,y,z]=cylinder(3,500);%cylinder是生成柱体的函数
surf(x,y,z)
title('实验七第五题圆柱体的光照和材料处理');
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
axis([-5,5,-5,5,0,1])
grid off;
light('Color','r','Position',[-4,0,0],'Style','infinite');
shading interp;
material shiny;
view(0,10);
lighting phong;
axis off;
实验九
程序:
I1=quad('sqrt(cos(t.^2)+4*sin(2*t).^2+1)',0,2*pi) I2=quad('(log(1+x))./(1+x.*x)',0,1)
程序:
A=[6,5,-2,5;9,-1,4,-1;3,4,2,-2;3,-9,0,2]
b=[-4;13;1;11]
x=inv(A)*b
实验十
程序:
x=sym('6');
y=sym('5');
z=(x+1)/(sqrt(3+x)-sqrt(y))分解因式
(1)
程序:
syms x y;
A=x^4-y^4;
factor(A)
(2)
程序:
factor(sym('5135'))
3、化简表达式
(1)
程序:
syms beta1 beta2
y=sin(beta1)*cos(beta2)-cos(beta1)*sin(beta2)
simple(y)
(2)
程序:
syms x
y=(4*x^2+8*x+3)/(2*x+1)
simple(y)
4.(1)p1=sym(‘[0 1 0;1 0 0;0 01]’);p2= sym(‘[1 0 0;0 1 0;1 0 1]’);A= sym(‘[a b c;d e f;g h l]’);
B=P1*P2*A
(2)inv(B) (3)tril(B) (4)determ(B)
5、用符号方法求下列极限或导数
(1)
程序:
syms x
f=(x*(exp(sin(x))+1)-2*(exp(tan(x))-1))/(sin(x)) limit(f)
(2)
程序:
syms x
y=(sqrt(pi)-sqrt(acos(x)))/(sqrt(x+1));
limit(f,x,-1,'right')
(3)
程序:
syms x
y=(1-cos(2*x))/x;
y1=diff(y)
y2=diff(y,x,2)
6、用符号方法求下列积分
(1)
程序:
syms x
f=1/(1+x^4+x^8)
int(f)
(2)
程序:
syms x
f=1/(((asin(x))^2)*sqrt(1-x^2)) int(f)
(3)
程序:
syms x
f=(x^2+1)/(x^4+1)
int(f,x,0,inf)
(4)
程序:
syms x
f=exp(x)*(1+exp(x))^2 y=int(f,x,0,log(2)) double(y)。