% T1
% 最好还是设 h=2 D=1
clear,clc;
h=2;D=1;
x=-2*D:0.01:2*D;
y=h*(x>D)+h/D.*x.*(abs(x)<=D)-h*(x<-D);
% T_2
clear,clc;
%用 cumsum函数
% A = (0:63);
% B = cumsum(2.^A);
% S = B(64) %用for循环
% clear,clc
% s=0;
% for i=0:63
% s = s+2.^i;
% end
% s %用sum函数
clear,clc
sum(2.^[0:63])
% T_3
clear,clc
x1=1;
xn = x1/2+3/2*x1;
y = xn/2+3/2*xn;
disp(abs(y-xn));
while abs(y-xn)>10e-14
xn = y;
y = xn/2+3/2*xn;
end
y;
% T_4
clc,clear
x=0; y=0;
for i=1:30000
x(i+1)=1+y(i)-1.4*x(i)^2;
y(i+1)=0.3*x(i);
end
%plot(x,y);
plot(x,y,'.');
% T_5   两个脚本文件

% bisect5.m
<pre name="code" class="plain">function [c,err,yc]=bisect5(f,a,b,delta)
%Input - f is the function
% - a and b are the left and right endpoints
% - delta is the tolerance
%Output - c is the zero
% - yc= f(c)
% - err is the error estimate for c
%If f is defined as an M-file function use the @ notation
% call [c,err,yc]=bisect(@f,a,b,delta).
%If f is defined as an anonymous function use the
% call [c,err,yc]=bisect(f,a,b,delta).
ya=f(a);
yb=f(b);
if ya*yb > 0,return,end
max1=1+round((log(b-a)-log(delta))/log(2));
for k=1:max1
c=(a+b)/2;
yc=f(c);
if yc==0
a=c;
b=c;
elseif yb*yc>0
b=c;
yb=yc;
else
a=c;
ya=yc;
end
if b-a < delta,break,end
end
c=(a+b)/2;
err=abs(b-a);
yc=f(c); % 1_5.m
<pre name="code" class="plain">clc,clear
format long
[answerr,error,value]=bisect5(@(x)x^2*sin(0.1*x+2)-3,0,1000,1e-8)



% T_6
clc,clear
t=[0,120,240,0]*pi/180; % 变换成弧度
x=[]; y=[];
for i=0:5:360
tt=i*pi/180;
x=[x; cos(tt+t)]; y=[y; sin(tt+t)];
end
plot(x',y','r'), axis('square')
% T_7
clc,clear
f=@(x,y,z)(x.^x+x.*y+x.*z).*exp(-z)+z.*z.*y.*x+sin(x+y+z.*z);%定义函数 f=x^2+y^2+z^2-10
[x,y,z]=meshgrid(linspace(-4,4,25));%设定网格大小和范围
val=f(x,y,z);
[p,v]=isosurface(x,y,z,val,0);%用 isosurface 得到函数 f=0 图形的点和面
patch('faces',p,'vertices',v,'facevertexcdata',jet(size(v,1)),'facecolor','w','edgecolor','flat');%
% 用 patch 绘制三角网格图并设定色彩
view(3);
grid on;
axis equal
% T_8
clc,clear
% xy的三维图与等高线
% [x,y]=meshgrid(-1:.1:1);
% surf(x,y,x.*y), figure; contour(x,y,x.*y,30) %sin xy 的三维图与等高线
[x,y]=meshgrid(-pi:.1:pi);
surf(x,y,sin(x.*y)), figure; contour(x,y,sin(x.*y),30)

最新文章

  1. psutil一个基于python的跨平台系统信息跟踪模块
  2. 常用的JAVA集合讲解
  3. BestCoder Round #41
  4. 搭建DHCP服务器以及DHCP中继服务器
  5. Oracle 删除大表中部分数据
  6. 浅析KMP算法
  7. 感知机学习算法 python实现
  8. c# 可以设置透明度的 Panel 组件
  9. 一个tomcat上放多个webapp问题,那这多个webapp会不会竞争端口呢?不会!安全两码事
  10. java_SSH整合1
  11. Google maps API开发(一)(转)
  12. iOS 9之New System Fonts(San Francisco 字体)
  13. CentOS: make menuconfig error: curses.h: No such file or directory
  14. asp.net MVC 路由系统
  15. java equals 和 == 的区别
  16. CV code references
  17. 在龙芯小本上安装Debain8.10
  18. tensorflow由于未初始化变量所导致的错误
  19. rem布局原理深度理解(以及em/vw/vh)
  20. CSS :after、before、&lt;!DOCTYPE&gt;

热门文章

  1. 使用Micrisoft.net设计方案 第三章Web表示模式 Web模式集群详细介绍 Observer(观察器)
  2. vc++中 .H 头文件引用的顺序与符号关系
  3. Detectron-MaskRCnn:Mask判别和获取前向Mask的标签
  4. HDU_2844_(多重背包)
  5. jquery选择器,筛选器,属性,事件 基础
  6. CAD设置背景图片
  7. Maven 项目debug调试时报Source not found.异常
  8. 解决移动端 手机号input 属性为 number,maxlength无效情况
  9. Linux学习笔记(五) 账号管理
  10. python3 时间模块 random模块之两个小练习