% t1% may wish to set 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;% with cumsum function% A = (0:63),% B = Cumsum (2.^a),% S = B (64)% with for loop% clear,clc% s=0;% for i=0:63% S = s+2.^i; % end% s% with Sum function 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);p lot (x, Y, '. ');
% t_5 Two script files% 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 a m-file function use" @ notation% call [C,err,yc]=bisect (@f,a,b,de LTA).%I F f is defined as an anonymous function with the% call [C,err,yc]=bisect (F,a,b,delta). Ya=f (a); Yb=f (b); if Ya*yb > 0,retur N,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<pre name= "code" Class= "plain" >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; % transformed into radians 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,clear[email protected] (x, Y, z) (x.^x+x.*y+x.*z). *exp (-Z) +z.*z.*y.*x+sin (x+y+z.*z);% definition function f=x^2+y^2+z^2-10[x , Y,z]=meshgrid (Linspace ( -4,4,25));% set grid size and range val=f (x, y, z); [P,v]=isosurface (x,y,z,val,0);% uses isosurface to get functions f=0 graphics points and patches (' faces ', p, ' vertices ', V, ' Facevertexcdata ', Jet (size (v,1)), ' Facecolor ', ' w ', ' edgecolor ', ' flat '); Make a triangular grid plot with patches and set the color view (3); grid On;axis Equal
% t_8clc,clear% XY's three-dimensional graph with contours% [X,y]=meshgrid ( -1:.1:1);% Surf (x,y,x.*y), figure; Contour (x,y,x.*y,30)%sin XY The three-dimensional graphs and contours [X,y]=meshgrid (-PI:.1:PI); Surf (X,y,sin (x.*y)), figure; Contour (X,y,sin (x.*y), 30)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Matlab Preliminary interview Sledgehammer __ Little Practice