1. % T1
  2. % 最好还是设 h=2 D=1
  3. clear,clc;
  4. h=2;D=1;
  5. x=-2*D:0.01:2*D;
  6. y=h*(x>D)+h/D.*x.*(abs(x)<=D)-h*(x<-D);
  1. % T_2
  2. clear,clc;
  3. %用 cumsum函数
  4. % A = (0:63);
  5. % B = cumsum(2.^A);
  6. % S = B(64)
  7.  
  8. %用for循环
  9. % clear,clc
  10. % s=0;
  11. % for i=0:63
  12. % s = s+2.^i;
  13. % end
  14. % s
  15.  
  16. %用sum函数
  17. clear,clc
  18. sum(2.^[0:63])
  1. % T_3
  2. clear,clc
  3. x1=1;
  4. xn = x1/2+3/2*x1;
  5. y = xn/2+3/2*xn;
  6. disp(abs(y-xn));
  7. while abs(y-xn)>10e-14
  8. xn = y;
  9. y = xn/2+3/2*xn;
  10. end
  11. y;
  1. % T_4
  2. clc,clear
  3. x=0; y=0;
  4. for i=1:30000
  5. x(i+1)=1+y(i)-1.4*x(i)^2;
  6. y(i+1)=0.3*x(i);
  7. end
  8. %plot(x,y);
  9. plot(x,y,'.');
  1. % T_5 两个脚本文件
  2.  
  3. % bisect5.m
  4. <pre name="code" class="plain">function [c,err,yc]=bisect5(f,a,b,delta)
  5. %Input - f is the function
  6. % - a and b are the left and right endpoints
  7. % - delta is the tolerance
  8. %Output - c is the zero
  9. % - yc= f(c)
  10. % - err is the error estimate for c
  11. %If f is defined as an M-file function use the @ notation
  12. % call [c,err,yc]=bisect(@f,a,b,delta).
  13. %If f is defined as an anonymous function use the
  14. % call [c,err,yc]=bisect(f,a,b,delta).
  15. ya=f(a);
  16. yb=f(b);
  17. if ya*yb > 0,return,end
  18. max1=1+round((log(b-a)-log(delta))/log(2));
  19. for k=1:max1
  20. c=(a+b)/2;
  21. yc=f(c);
  22. if yc==0
  23. a=c;
  24. b=c;
  25. elseif yb*yc>0
  26. b=c;
  27. yb=yc;
  28. else
  29. a=c;
  30. ya=yc;
  31. end
  32. if b-a < delta,break,end
  33. end
  34. c=(a+b)/2;
  35. err=abs(b-a);
  36. yc=f(c);
  37.  
  38. % 1_5.m
  39. <pre name="code" class="plain">clc,clear
  40. format long
  41. [answerr,error,value]=bisect5(@(x)x^2*sin(0.1*x+2)-3,0,1000,1e-8)
  1.  
  1.  
  1. % T_6
  2. clc,clear
  3. t=[0,120,240,0]*pi/180; % 变换成弧度
  4. x=[]; y=[];
  5. for i=0:5:360
  6. tt=i*pi/180;
  7. x=[x; cos(tt+t)]; y=[y; sin(tt+t)];
  8. end
  9. plot(x',y','r'), axis('square')
  1. % T_7
  2. clc,clear
  3. 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
  4. [x,y,z]=meshgrid(linspace(-4,4,25));%设定网格大小和范围
  5. val=f(x,y,z);
  6. [p,v]=isosurface(x,y,z,val,0);%用 isosurface 得到函数 f=0 图形的点和面
  7. patch('faces',p,'vertices',v,'facevertexcdata',jet(size(v,1)),'facecolor','w','edgecolor','flat');%
  8. % patch 绘制三角网格图并设定色彩
  9. view(3);
  10. grid on;
  11. axis equal
  1. % T_8
  2. clc,clear
  3. % xy的三维图与等高线
  4. % [x,y]=meshgrid(-1:.1:1);
  5. % surf(x,y,x.*y), figure; contour(x,y,x.*y,30)
  6.  
  7. %sin xy 的三维图与等高线
  8. [x,y]=meshgrid(-pi:.1:pi);
  9. surf(x,y,sin(x.*y)), figure; contour(x,y,sin(x.*y),30)

matlab初试牛刀__小练习的更多相关文章

  1. 周末充电之WPF(一).初试牛刀

    追的剧已经赶上更新的速度了,突然觉得一下子就闲了.趁着这点时间,刚好学点 WPF .看到这边,好多人估计得感叹技术宅约等于单身狗,哈哈.好了,赶紧进入学习状态. 关注 WPF 或者说对它感兴趣其实多半 ...

  2. OpenCV:初试牛刀-带滚动条的视频播放-2

    视频播放时点击窗口关闭按钮(即小叉号)关闭窗口 隐藏console控制台 使用VideoCapture和createTrackbar实现滚动条控制视频播放 #include<iostream&g ...

  3. OpenCV:初试牛刀-显示图像-1

    OpenCV开发包提供了读取各种类型的图像文件.视频内容以及摄像机输入的功能.这些功能是OpenCV开发包所包含的HighGUI工具集的一部分. 先看两个小例子: #include"open ...

  4. redis初试牛刀

    先来无事就学学redis.可是并没有想的那么美好.首先要解释一下,redis主流是安装在lunx系统中的,甚至官网直接没有给出windows版本.要下载windows只能去所谓的githup.好吧我在 ...

  5. python初试牛刀

    需求:在L7的一台机器上做nginx配置,然后代码分发到别的所有的机器上.由于目录中有很多配置文件,而且防止误操作,需要修改配置之前先备份原配置.然后需要在运行修改配置的脚本之前,先弹出界面,告知操作 ...

  6. HBase 2、HBase安装与初试牛刀

    官方帮助文档:http://hbase.apache.org/book.html  PDF:http://hbase.apache.org/apache_hbase_reference_guide.p ...

  7. iOS 视图调试器(Debug View Hierarchy) 之 初试牛刀

    参考:http://blog.csdn.net/th_gsb/article/details/44856795 由于iOS的界面开发大多都是用代码实现的,编写的时候,那就是看不见摸不着的情况.所以,如 ...

  8. PyQt4 初试牛刀一

    建立了一个MainWindow,创建最基本的菜单栏.状态栏.工具栏,并重新定义了"X"关闭的默认行为. # -*- coding: utf-8 -*- import sys fro ...

  9. PyQt4 初试牛刀二

    一.最小话托盘后,调用showNormal()后窗口不刷新,解决办法如下: 重写showNormal 方法,调用父类方法后,repaint窗体 def showNormal(self):     su ...

随机推荐

  1. leetcode126 Word Ladder II

    思路: 宽搜过程中分层记录路径,递归还原.实现: class Solution { public: void getPath(string now, string beginWord, string ...

  2. CF811C Vladik and Memorable Trip

    思路: 令dp[i]表示前i个的最大舒适度.则如果区间[j, i](1 < j <= i)满足条件,有如下转移:dp[i] = max(dp[i], dp[j - 1] + cur).其中 ...

  3. Elasticsearch--预匹配器

    当你对一个无限输入数据流进行操作并搜索特定事件的出现时,可以使用此模型.可以用于检测监控系统中的故障. 在新版本中的知识点位置https://www.elastic.co/guide/en/elast ...

  4. python网络爬虫。第一次测试-有道翻译

    2018-03-0720:53:56 成功的效果如下 代码备份 # -*- coding: UTF-8 -*- from urllib import request from urllib impor ...

  5. Android基础TOP5_2:MultiAutoCompleteTextView多文本自动补全文本框

    Activity: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...

  6. JS高级——弹出框的美化

    替换原有的alert方法,window.alert=function(){} https://blog.csdn.net/kirsten_z/article/details/76242286 http ...

  7. linux 拆分文件

    split [OPTION]... [INPUT [PREFIX]] :根据行或者大小拆分文件 split file_name :默认把文件file_name拆分成xaa,xab,xac,...... ...

  8. 梦想CAD控件网页版扩展数据

    随着基于CAD的应用软件飞速发展,经常需要保存一些与图形可视性无关的数据,即非图形参数.例如在绘制化验样图中包含品位数据.MxCAD定义一类新的参数——实体扩展数据.扩展数据与实体的可视性无关,而是用 ...

  9. Spring Boot 创建hello world项目

    Spring Boot 创建hello world项目 1.创建项目 最近在学习Spring Boot,这里记录使用IDEA创建Spring Boot的的过程 在1出勾选,选择2,点击Next 这里填 ...

  10. 虚拟机找不到本机vmnet0,vmnet8,无法连接xshell,解决方案

    首先出现这个问题肯定是第一次下载虚拟机把之前的注册表覆盖了,网卡找不到,首先卸载VMware 并且将C\ProgramData下的VMware文件夹删除掉 ,下载cceaner,点击注册表清除干净,再 ...