博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
matlab初试牛刀__小练习
阅读量:7086 次
发布时间:2019-06-28

本文共 1995 字,大约阅读时间需要 6 分钟。

% T1% 不妨设 h=2 D=1clear,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_2clear,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,clcsum(2.^[0:63])

% T_3clear,clcx1=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;endy;

% T_4clc,clearx=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
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,endmax1=1+round((log(b-a)-log(delta))/log(2));for k=1:max1c=(a+b)/2;yc=f(c);if yc==0a=c;b=c;elseif yb*yc>0b=c;yb=yc;elsea=c;ya=yc;endif b-a < delta,break,endendc=(a+b)/2;err=abs(b-a);yc=f(c);% 1_5.m
clc,clearformat long [answerr,error,value]=bisect5(@(x)x^2*sin(0.1*x+2)-3,0,1000,1e-8)
 

 

% T_6clc,cleart=[0,120,240,0]*pi/180; % 变换成弧度x=[]; y=[];for i=0:5:360tt=i*pi/180;x=[x; cos(tt+t)]; y=[y; sin(tt+t)];endplot(x',y','r'), axis('square')

% T_7clc,clearf=@(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_8clc,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)

转载于:https://www.cnblogs.com/Genesis2018/p/8304765.html

你可能感兴趣的文章
wake-up signal SIGALRM from alarm() or setitimer(). SIG_DFL & SIG_IGN
查看>>
HTTP/2 对 Web 性能的影响(上)
查看>>
react更新state的时候要返回一个全新的引用或者值
查看>>
flex实战
查看>>
Android 高仿腾讯新闻视频切换效果
查看>>
只有程序员才能看懂的15个瞬间
查看>>
Mybatis入门学习---使用注解开发
查看>>
影响网站关键词排名的因素
查看>>
我的友情链接
查看>>
read和变量设定方式
查看>>
Winmail + Rsync + Nmap 实现 Winmail 邮件系统双机热备
查看>>
python读写文件
查看>>
1-4常用路由协议的梳理
查看>>
Javascript核心
查看>>
利用UltraISO制作RedhatU盘启动盘
查看>>
一分钟教你快速建立起MySQL/Mariadb 主从状态检测脚本(shell)
查看>>
hive函数 -- regexp_extract
查看>>
C# vs2010 调用webservice
查看>>
Samba用户管理机制
查看>>
解决securecrt连接centos使用VIM编辑中文时乱码
查看>>