Matlab期末复习
一,《MATLAB》课程课堂练习(四)
(1)
clear
syms x
x = -10:0.011:10;
y = x.^2.*(x < 1) + (x + 1).*(x >= 1);
plot(x,y);
grid on
(2)
clear
syms x
f1 = x.^2;
f2 = x + 1;
hold on
r1 = limit(f1,x,1,'left')
r2 = limit(f2,x,1,'right')
ezplot(f1);ezplot(f2);
grid on
plot(1,1,'r.')
plot(1,2,'r.')
title('图像')
(3)
不难发现左右极限不相等,故极限不存在
2.求1~100000间整数的立方和
clear
s = 0;
for k = 1:100000;
s = s+ k^3
end
3.利用for循环求1!+2!+3!+ 4!+5!的值
clear
s = 1;
sum = 0;
for i = 1:5
for j = 1:i
s = s*j
end
sum = sum + s;
s = 1;
end
sum