两道题的代码
1条回答 默认 最新
- joel_1993 2021-09-11 17:49关注
同学你好,这个都是一个意思:
3(1)function s = fun1(n) k = 1:n; s = sum(1./(k.*(k+1))); end
3(2)
function s = fun2(n) k = 1:n; s = sum((2+(-1).^(k))./2.^k; end
3(3)
function s = fun3(n) k = 1:n; s = sum(1./factorial(k-1)); end
3(3)
function s = fun4(n) k = 1:n; s = sum(sqrt(k+1).*(1-cos(pi./k))); end
4
(1)x=linspace(0,2*pi,100); figure(1) subplot(2,2,1) plot(x,sin(5*x)); subplot(2,2,2) plot(x,cos(3*x)); subplot(2,2,3) plot(x,sin(5*x).*cos(3*x)); subplot(2,2,4) plot(x,sin(5*x)+cos(3*x));
(2)
x=linspace(0,2*pi,100); plot(x,sin(x),'r-') hold on plot(x,sin(5*x)) plot(x,sin(x)+sin(5*x)) legend('sinx','sin5x','sin(x)+sin(5x)')
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报