Upload original Matlab程序设计 course files (part 2)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Binary_Search.m+11-3
- matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Dijkstra/MINROUTE.M+34-3
- matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Dynamic_pro/DYNPROG.M+86-3
- matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Floyd/floyd.m+27-3
- matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/Untitled.m+67-3
- matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/test_exe.m+4-3
- matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/test_exe_main.cpp+30-3
- matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/timestwo/timestwo.c+16-3
- matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/timestwo/timestwo.dll
- matlab数学建模算法/matlab经典算法的程序/MATLAB/tayloretc.m+13-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/biology.m+14-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/boyin.m+18-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/df1.m+3-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/df2.m+12-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/diechaos.m+24-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/erfenfa.m+19-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/exampleg.m+8-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/exampleg1.m+13-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplegs.m+10-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplejac.m+10-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplesor.m+22-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/f1.m+3-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/f2.m+7-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gausei.m+40-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gauss.m+32-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gauss1.m+46-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gexian.m+14-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/jac.m+33-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainerfen.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/maingexian.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainnewton.m+12-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainnewton1.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/newton.m+14-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/newton1.m+15-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/sor.m+39-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/sparfull.m+20-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/fun1.m+3-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funconstr.m+4-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funfmins.m+4-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funfminu.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funrosen.m+2-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/rosen.m+12-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase1.m+4-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase2.m+9-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase3.m+9-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase4.m+9-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq1.m+4-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq2.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq3.m+5-3
- matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq4.m+5-3
123version https://git-lfs.github.com/spec/v1oid sha256:4aad050656e98af5ef9b660fdc5b525e388d094d431c947ae7e5c0437d75613asize 4041234567891011function Binary_Search(L,a,b,x)%c����beginif a>b then return(-1)else beginm:=(a+b) div 2;if x=L[m] then return(m)else if x>L[m]then return(Binary_Search(L,m+1,b,x));else return(Binary_Search(L,a,m-1,x));end;end;
123version https://git-lfs.github.com/spec/v1oid sha256:bc383609b78e5ef633e5819d5e9ebe7651c3ff3be039ad84b6822ea5e74a3aaasize 125912345678910111213141516171819202122232425262728293031323334function [S,D]=minRoute(i,m,W)%ͼ���������������·����Dijkstra�㷨 M-����%��ʽ [S,D]=minroute(i,m,W)% iΪ���·������ʼ��,mΪͼ������,WΪͼ�Ĵ�Ȩ�ڽӾ���% �����ɱߵ�������֮���Ȩ��inf��ʾ����ʾ���Ϊ��S��ÿ% һ�д��ϵ��¼�¼�˴�ʼ�㵽�յ�����·�������������ţ�% D��һ����������¼��S����ʾ·���Ĵ�С;%����% clear;w=inf*ones(6);w(1,3)=10;w(1,5)=30;% w(1,6)=100;w(2,3)=5;w(3,4)=50;w(4,6)=10;% w(5,4)=20;w(5,6)=60;% i=1;[s,d]=minroute(i,6,w)% By X.D. Ding June 2000dd=[];tt=[];ss=[];ss(1,1)=i;V=1:m;V(i)=[];dd=[0;i];% dd�ĵڶ�����ÿ����������·�����յ㣬��һ�������·����ֵkk=2;[mdd,ndd]=size(dd);while ~isempty(V)[tmpd,j]=min(W(i,V));tmpj=V(j);for k=2:ndd[tmp1,jj]=min(dd(1,k)+W(dd(2,k),V));tmp2=V(jj);tt(k-1,:)=[tmp1,tmp2,jj];endtmp=[tmpd,tmpj,j;tt];[tmp3,tmp4]=min(tmp(:,1));if tmp3==tmpd, ss(1:2,kk)=[i;tmp(tmp4,2)];else,tmp5=find(ss(:,tmp4)~=0);tmp6=length(tmp5);if dd(2,tmp4)==ss(tmp6,tmp4)ss(1:tmp6+1,kk)=[ss(tmp5,tmp4);tmp(tmp4,2)];else, ss(1:3,kk)=[i;dd(2,tmp4);tmp(tmp4,2)];end;enddd=[dd,[tmp3;tmp(tmp4,2)]];V(tmp(tmp4,3))=[];[mdd,ndd]=size(dd);kk=kk+1;end; S=ss; D=dd(1,:);
123version https://git-lfs.github.com/spec/v1oid sha256:ab9ef86cd6f10ff0289bf031250390694cfe9dbe36752b49d1019cf44f7df6b0size 31511234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586function [p_opt,fval]=dynprog(x,DecisFun,ObjFun,TransFun)% [p_opt,fval]=dynprog(x,DecisFun,ObjFun,TransFun)% ����ʼ�˺��ն˵Ķ�̬�滮,��ָ�꺯����Сֵ�������㷨�ݹ�% �������x��״̬������һ�д���һ����״̬��M-����% DecisFun(k,x)�ɽ�k��״̬����x�����Ӧ���������߱���;% M-����ObjFun(k,x,u)�ǽ�ָ�꺯����M-����TransFun(k,x,u)% ��״̬ת�ƺ���,����x�ǽ�k��ij״̬������u����Ӧ�ľ��߱�����% ���p_opt��4�й��ɣ�p_opt=[�����;���Ų�����;���Ź�����;% ָ�꺯��ֵ��]��fval��һ������������Ԫ�طֱ��ʾp_opt��% ���Ų������Ӧʼ��״̬x�����ź���ֵ��%%�����ο��������ȱࡶ��ѧʵ��--ʹ��MATLAB��P180%��д3������% eg13f1_2.m% function u=DecisF_1(k,x)% �ڽ�k��״̬����x��ֵ�������Ӧ�ľ��߱������е�ȡֵ% c=[70,72,80,76];q=10*[6,7,12,6];% if q(k)-x<0,u=0:100; %���߱�������ȡΪ��ֵ% else,u=q(k)-x:100;end; %�������������Ҳ�����100% u=u(:);% eg13f2_2.m% function v=ObjF_1(k,x,u)% ��k��ָ�꺯��% c=[70,72,80,76];v=c(k)*u+2*x;% eg13f3_2.m% function y=TransF_1(k,x,u)% ״̬ת�Ʒ���% q=10*[6,7,12,6];y=x+u-q(k);%����DynProg.m�������£�% clear;x=nan*ones(14,4);% x��10�ı��������Χ0��x��130,% %���x=0,1,...13������x��ʼ��ȡ14�У�nan��ʾ������Ԫ��% x(1:7,1)=10*(0:6)'; % ���¶���x�Ŀ���ȡֵ% x(1:11,2)=10*(0:10)';x(1:12,3)=10*(2:13)';% x(1:7,4)=10*(0:6)';% [p,f]=dynprog(x,'eg13f1_2','eg13f2_2','eg13f3_2')% By X.D. Ding June 2000k=length(x(1,:));f_opt=nan*ones(size(x));d_opt=f_opt;t_vubm=inf*ones(size(x));x_isnan=~isnan(x);t_vub=inf;% �����ն����ֵtmp1=find(x_isnan(:,k));tmp2=length(tmp1);for i=1:tmp2u=feval(DecisFun,k,x(i,k));tmp3=length(u);for j=1:tmp3tmp=feval(ObjFun,k,x(tmp1(i),k),u(j));if tmp<=t_vub,f_opt(i,k)=tmp;d_opt(i,k)=u(j);t_vub=tmp;end;end;end% ���Ƽ�����εĵݹ���ó���for ii=k-1:-1:1tmp10=find(x_isnan(:,ii));tmp20=length(tmp10);for i=1:tmp20u=feval(DecisFun,ii,x(i,ii));tmp30=length(u);for j=1:tmp30tmp00=feval(ObjFun,ii,x(tmp10(i),ii),u(j));tmp40=feval(TransFun,ii,x(tmp10(i),ii),u(j));tmp50=x(:,ii+1)-tmp40;tmp60=find(tmp50==0);if ~isempty(tmp60),tmp00=tmp00+f_opt(tmp60(1),ii+1);if tmp00<=t_vubm(i,ii)f_opt(i,ii)=tmp00;d_opt(i,ii)=u(j);t_vubm(i,ii)=tmp00;end;end;end;end;end;fval=f_opt(tmp1,1);% ��¼���ž��ߡ����Ź��ߺ���Ӧָ�꺯��ֵp_opt=[];tmpx=[];tmpd=[];tmpf=[];tmp0=find(x_isnan(:,1));tmp01=length(tmp0);for i=1:tmp01,tmpd(i)=d_opt(tmp0(i),1);tmpx(i)=x(tmp0(i),1);tmpf(i)=feval(ObjFun,1,tmpx(i),tmpd(i));p_opt(k*(i-1)+1,[1,2,3,4])=[1,tmpx(i),...tmpd(i),tmpf(i)];for ii=2:ktmpx(i)=feval(TransFun,ii-1,tmpx(i),tmpd(i));tmp1=x(:,ii)-tmpx(i);tmp2=find(tmp1==0);if ~isempty(tmp2)tmpd(i)=d_opt(tmp2(1),ii);end;tmpf(i)=feval(ObjFun,ii,tmpx(i),tmpd(i));p_opt(k*(i-1)+ii,[1,2,3,4])=[ii,tmpx(i),...tmpd(i),tmpf(i)];end;end;
123version https://git-lfs.github.com/spec/v1oid sha256:3939d7eee97b57205ce5648e3652bfd72cf5f6be2c6ac9d37b9855edb309c21asize 563123456789101112131415161718192021222324252627function [d,r]=floyd(a)%floyd.m%����floyd�㷨����ͼa��ÿ�Զ������·%d�Ǿ������%r��·�ɾ���n=size(a,1);d=a;for i=1:nfor j=1:nr(i,j)=j;endendrfor k=1:nfor i=1:nfor j=1:nif d(i,k)+d(k,j)<d(i,j)d(i,j)=d(i,k)+d(k,j);r(i,j)=r(i,k)endendendkdrend
123version https://git-lfs.github.com/spec/v1oid sha256:238e1da8b9958d956f95def56745a257e3f26da6da76daa8c75dda61e1348e63size 136212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667%sjbh.mfunction sjbh1(m)x=-1:0.01:10;y1=sin(x);plot(x,y1)axis([-1 10 -2 2])gridlegend('sin(x)')pause(2)legend offlegend('��y=sin(x)�ĺ�����������ԭ����1/2')%hold on%theax=axis;pause%y=sinx->y=sin(wx)h=line('Color',[1 1 0],'Marker','.','MarkerSize',4,'EraseMode','xor');w=1:0.05:2;y2=zeros(1101,21);for i=1:21y2(:,i)=sin(w(i)*x');set(h,'xdata',x,'ydata',y2(:,i));drawnow;pause(0.0005)i=i+1;%axis=theax;endlegend offlegend('sin(2x)')pause(2)legend('��y=sin(2x)����ƽ��pi/6')%hold onpause%y=sin(wx)->y=sin(wx+pi/3)h=line('Color',[1 0 1],'Marker','.','MarkerSize',4,'EraseMode','Xor');w1=2;y3=zeros(1101,20);for i=1:20y3=(:,i)=sin(w1*x'+pi/60*i);set(h,'xdata',x,'ydata',y3(:,i));drawnow;pause(0.0005)i=i+1;%axis=theax;endlegend offlegend('sin(2x+pi/3)')pause(2)legend('��y=sin(2x)����ƽ��pi/6')%y=sin(wx+pi/3)->y=2sin(wx+pi/3)pause%y=sin(wx)->y=sin(wx+pi/3)h=line('Color',[1 0 1],'Marker','.','MarkerSize',5,'EraseMode','Xor');w3=1:0.05:2;y4=zeros(1101,21);for i=1:21y4=(:,i)=w3(i)*sin(w1*x'+pi/60*i);set(h,'xdata',x,'ydata',y4(:,i));drawnow;%pause(0.0005)i=i+1;%axis=theax;endlegend offlegend('sin(2x+pi/3)')legend off%pause(2)%legend('��y=sin(2x)����ƽ��pi/6')
123version https://git-lfs.github.com/spec/v1oid sha256:689387fbef8fe0e0a45af56e62da7296efd0e31af06f2f24388ce45bb48ba87esize 761234function [out]=test_exe()out=100*188*sqrt(100);disp('out=');disp(out);
123version https://git-lfs.github.com/spec/v1oid sha256:49688c22c971b673e2ae947f7d4edea3940e5a59e1950c1680372047726e9aa4size 1164123456789101112131415161718192021222324252627282930//// MATLAB Compiler: 3.0// Date: Thu Sep 02 20:52:11 2004// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"// "array_indexing:on" "-O" "optimize_conditionals:on" "-p" "-W" "main" "-L"// "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "test_exe.m"//#include "libmatlb.hpp"#include "test_exe.hpp"extern _mexcpp_information _main_info;static mexFunctionTableEntry function_table[1]= { { "test_exe", mlxTest_exe, 0, 1, &_local_function_table_test_exe } };static _mexcppInitTermTableEntry init_term_table[1]= { { InitializeModule_test_exe, TerminateModule_test_exe } };_mexcpp_information _main_info= { 1, 1, function_table, 0, NULL, 0, NULL, 1, init_term_table };//// The function "main" is a Compiler-generated main wrapper, suitable for// building a stand-alone application. It calls a library function to perform// initialization, call the main function, and perform library termination.//int main(int argc, const char * * argv) {return mwMain(argc, argv, mlxTest_exe, 1, &_main_info);}
123version https://git-lfs.github.com/spec/v1oid sha256:b542628bc196534ad2502430f289e19c9fc260fa2817502fbec39b7175da870esize 35612345678910111213141516#include "mex.h"void timestwo(double y[],double x[]){y[0]=2.0*x[0];}void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]){double *x,*y;int mrows,ncols;mrows=mxGetM(prhs[0]);ncols=mxGetN(prhs[0]);plhs[0]=mxCreateDoubleMatrix(mrows,ncols,mxREAL);x=mxGetPr(prhs[0]);y=mxGetPr(plhs[0]);timestwo(y,x);}
123version https://git-lfs.github.com/spec/v1oid sha256:1c408b99f570b86b12ee011ad27892af056af848638cc615d5b00a002f50350esize 19912345678910111213clearclcsyms x;f='x^2*(sin(x))^2';diff(f);f1=simple(ans)diff(f,x,2);f2=simple(ans)diff(f,x,3);f3=simple(ans)diff(f,x,4); f4=simple(ans)int(f4,x)taylor(x^2*(sin(x))^2,15,x)
123version https://git-lfs.github.com/spec/v1oid sha256:db570d8c947d75893242e15da377b6fa2773e196d7e69ecd902f98658ec4156asize 1881234567891011121314clear;n=10000;x=zeros(n,1);x(1)=0.1;i=1;while i<nx(i+1)=4*x(i)*(1-x(i));i=i+1;endfor j=31:nplot(j,x(j),'b*')hold onend
123version https://git-lfs.github.com/spec/v1oid sha256:07ea1d70a75c9d664db1ccf17ab573954b9b203a4ab6d5c6ec3ab8f5c1d77daesize 248123456789101112131415161718h=0.5;a=0;b=8;n=80;d=(b-a)/n;for i=1:n+1pr(i)=a+(i-1)*d;p=pr(i);n=-78*p^2+655*p+125;x=h*n;r=p*x;c=50+1.5*x+8*x^(3/4);l(i)=r-c;endplot(pr,l);grid onxlabel('Price:p');title ('Profit Curve:R(p)');
123version https://git-lfs.github.com/spec/v1oid sha256:aae7df0696c32bba70412a801457c7b765b347be27d3ba17254e5fa9e0244962size 42123function b=df1(x)b=zeros(1,1);b=2*x+1;
123version https://git-lfs.github.com/spec/v1oid sha256:b710a5c86830b4be731d88ce35108dfb18af9907535f60cb93a58128314add84size 190123456789101112function A=df2(x);n=3;A=zeros(n,n);A(1,1)=2*x(1)-10;A(1,2)=2*x(2);A(1,3)=1;A(2,1)=x(2)^2;A(2,2)=2*x(1)*x(2);A(2,3)=2*x(3)-2;A(3,1)=2*x(1);A(3,2)=2*x(2)-3;A(3,3)=2*x(3);
123version https://git-lfs.github.com/spec/v1oid sha256:9f88891e1f2903440b0b40c9f7955bc907df349d1dd5f2cff9fec9cdb3dd40f8size 252123456789101112131415161718192021222324clear;n0=50;n=100;x=zeros(n,1);for r=1.7:0.01:3.6x(1)=0.5;i=1;while i<nx(i+1)=r*x(i)*(1-x(i));i=i+1;endfor j=n0:nplot(r,x(j),'b*')hold onendend
123version https://git-lfs.github.com/spec/v1oid sha256:9d7775e2932eb42cbb10027c95b10bc1b9e3d2e154ef58bb5509b2d09ab3cf27size 26012345678910111213141516171819function [U,step]=erfenfa(a,b)k=0;e=ones(1,1);while norm(e,2)>1e-6x=(a+b)/2;k=k+1;if f1(x)==0exitelseif f1(x)*f1(a)<0b=x;e=b-a;elseif f1(x)*f1(b)<0a=x;e=b-a;endendU=x;step=k;
123version https://git-lfs.github.com/spec/v1oid sha256:8bf6b5794b74f5167b3f271ac38abd641bd7fc00245a98bc387cfbf2199cd424size 15312345678a=[1 2 4 1 7;2 3 0 1 8;4 1 7 6 1;1 1 0 2 1;1 3 0 1 1]b=[15 14 19 5 6]'r=[a,b]n=5;[A,x]=gauss(r,n);disp('the solution of the equations:');Ax
123version https://git-lfs.github.com/spec/v1oid sha256:8b681f1ac9834c0e935c391c79b6c7c745e56eee4b31b8e607bb10ec63025692size 42812345678910111213a=[0 1 -1 1 0 0 0 0 0 0;0 0 0 1 1 0 0 0 0 0;0 0 0 0 0 -1 1 0 0 0;1 1 0 0 0 0 0 0 0 0;1 0 0 0 1 0 0 0 0 0;0 0 0 0 0 0 1 1 0 0;0 0 0 0 0 0 0 0 1 0;0 0 0 0 0 0 0 0 -1 1;0 0 0 0 0 0 0 0 0 1;0 0 1 0 0 1 0 1 0 0];%a=[1 2 4 1 7;2 3 0 1 8;4 1 7 6 1;1 1 0 2 1;1 3 0 1 1]%b=[15 14 19 5 6]'b=[300 500 200 800 800 1000 400 200 600 1000]';%n=5;n=10;[A,x]=gauss1(r,n);disp('the solution of the equations:');Ax
123version https://git-lfs.github.com/spec/v1oid sha256:73b8fdd92d921b7564bbc8535671e94453d96a049f0ea97fc46e8620d1a06e7fsize 15712345678910clear;a=[1 0 3 0;0 2 1 2;3 1 15 0;0 2 0 4];b=[1 6 5 8]';n=4;u=zeros(n,1);[X,K]=gausei(a,b,n,u);disp('������Ľ�:');Xdisp('�����Ĵ�����')K
123version https://git-lfs.github.com/spec/v1oid sha256:c8997fe0087961046217953657e4e8cec92e6d7c31a9b9489b548ff393cb0dcbsize 15412345678910clear;a=[1 0 3 0;0 2 1 2;3 1 15 0;0 2 0 4];b=[1 6 5 8]';n=4;u=zeros(n,1);[X,K]=jac(a,b,n,u);disp('������Ľ�:');Xdisp('�����Ĵ�����')K
123version https://git-lfs.github.com/spec/v1oid sha256:d93a53b78451f8bdbce919de8ce6e34f2cc79050c0148cf0836c3cfbef509614size 29412345678910111213141516171819202122clear;a=[4 -2 -4;-2 17 10;-4 10 9];b=[10 3 -7]';n=3;u=zeros(n,1);w=1;[X1,K1]=sor(a,b,n,u,w);disp('���ɳ�ϵ��:')wdisp('������Ľ�:');X1disp('�����Ĵ�����')K1w=1.46;[X2,K2]=sor(a,b,n,u,w);disp('���ɳ�ϵ��:')wdisp('������Ľ�:');X2disp('�����Ĵ�����')K2
123version https://git-lfs.github.com/spec/v1oid sha256:28f059378380f5e07449ecbb72adc5604c9005c59c6a44531ff71ff00aefa613size 47123function f=f1(x);f=zeros(1,1);f=x^2+x-14;
123version https://git-lfs.github.com/spec/v1oid sha256:2a9b3a5379ba9e964f628789b7d45c213746cfbfd57783be73fd31f45d5213e7size 1451234567function f=f2(x)n=3;f=zeros(n,1);f(1)=x(1)^2-10*x(1)+x(2)^2+x(3)+7;f(2)=x(1)*x(2)^2+x(3)^2-2*x(3);f(3)=x(1)^2+x(2)^2-3*x(2)+x(3)^2;
123version https://git-lfs.github.com/spec/v1oid sha256:f5b6bbe3d0b818bdc12adcce0c3cdc6e53e7abbd1adc7054cb292dad1b007701size 68612345678910111213141516171819202122232425262728293031323334353637383940%Gauss-Seidel��������function [x,sp]=gausei(a,b,n,x1)%���e=ones(n,1);%�����Ľ�����x2=zeros(n,1);%�����Ĵ���k=0;%�����û������Ҫ��ʱ��������while norm(e,2)>1e-6%ÿ��5����ʾ�������if (rem(k,5)==0)str=sprintf('X%d= %g %g %g %g\n',k,x1);disp(str)endk=k+1;%����x2��i��for i=1:ns1=0;s2=0;if i-1>0for j=1:i-1s1=s1+a(i,j)*x2(j);endendfor j=i+1:ns2=s2+a(i,j)*x1(j);endx2(i)=(b(i)-s1-s2)/a(i,i);end%�����������e=x2-x1;%��x2��Ϊ�µĵ�����ֵx1=x2;end%���ص�������sp=k;%���ص���ֵx=x2;
123version https://git-lfs.github.com/spec/v1oid sha256:c9bd6682ecb51c00c51b1d83a398dfb187df218fa0a5c8364e6e3965c5fba532size 6451234567891011121314151617181920212223242526272829303132%˳��gauss��ȥ����gauss����function [A,u]=gauss(a,n)for k=1:n-1%��ȥ����for i=k+1:nfor j=k+1:n+1%���a(k,k)=0,������ȥif abs(a(k,k))>1e-6%�����k�����������a(i,j)=a(i,j)-a(i,k)/a(k,k)*a(k,j);else%a(k,k)=0,˳��gauss��ȥʧ��disp('˳��gauss��ȥʧ��');pause;exit;endendendend%�ش�����x(n)=a(n,n+1)/a(n,n);for i=n-1:-1:1s=0;for j=i+1:ns=s+a(i,j)*x(j);endx(i)=(a(i,n+1)-s)/a(i,i);end%����gauss��ȥ����������A=triu(a);%���ط�����Ľ�u=x;
123version https://git-lfs.github.com/spec/v1oid sha256:5f338405039e955f2b46a82116243286d0884324995ce1ed6f0626dd029e0ac8size 79512345678910111213141516171819202122232425262728293031323334353637383940414243444546%����Ԫgauss��ȥ����function [A,u]=gauss(a,n)%��ȥ����for k=1:n-1%ѡ��Ԫc=0;for q=k:nif abs(a(q,k))>cc=a(q,k);l=q;endend%�����ԪΪ0�������A������if abs(c)<1e-10disp('error');pause;exit;end%���l������k��������l�к͵�k��if l~=kfor q=k:n+1temp=a(k,q);a(k,q)=a(l,q);a(l,q)=temp;endend%�����k����Ԫ��ֵfor i=k+1:nfor j=k+1:n+1a(i,j)=a(i,j)-a(i,k)/a(k,k)*a(k,j);endendend%�ش�����x(n)=a(n,n+1)/a(n,n);for i=n-1:-1:1s=0;for j=i+1:ns=s+a(i,j)*x(j);endx(i)=(a(i,n+1)-s)/a(i,i);end%��������Ԫgauss��ȥ����������A=triu(a);%���ط�����Ľ�u=x;
123version https://git-lfs.github.com/spec/v1oid sha256:097e31eff9a8cbeafbef931afacb1f3db144531d63cb5c026ec104caec3688fbsize 2411234567891011121314function [x,step]=newton2(x0,n)x(1)=x0;b=1;i=1;while (abs(b)>eps*x(i))x(i+1)=x(i)-f1(x(i))*(x(i)-x(i-1))/(f1(x(i))-f1(x(i-1)));b=x(i+1)-x(i);i=i+1;if i>nerror('n is full');endendx=x(i);step=i;
123version https://git-lfs.github.com/spec/v1oid sha256:b51bd17f3c355af3bd3c3d37ad599d12f89b5c2916446ca34b6a13239d82f09csize 559123456789101112131415161718192021222324252627282930313233%Jacobian��������function [x,sp]=jac(a,b,n,x1)%���e=ones(n,1);%�����Ľ�����x2=zeros(n,1);%�����Ĵ���k=0;%�����û������Ҫ��ʱ��������while norm(e,2)>1e-6%ÿ��5����ʾ�������if (rem(k,5)==0)str=sprintf('X%d= %g %g %g %g\n',k,x1);disp(str)endk=k+1;%����x2��i��for i=1:ns=0;for j=1:ns=s+a(i,j)*x1(j);endx2(i)=(b(i)-s)/a(i,i)+x1(i);end%�����������e=x2-x1;%��x2��Ϊ�µĵ�����ֵx1=x2;end%���ص�������sp=k;%���ص���ֵx=x2;
123version https://git-lfs.github.com/spec/v1oid sha256:db726a577da51f4ef09fdfc15d6f06b0da2604f7824450363443e5e7294d1a1dsize 3712345a=3;b=4;[x,k]=erfenfa(a,b);xk
123version https://git-lfs.github.com/spec/v1oid sha256:f16b19c4dc581a78256db01f8234d5ebb56db3e9549e6e4f375a7861f1eac019size 4312345x0=0;n=100;[x,k]=newton1(x0,n);xk
123version https://git-lfs.github.com/spec/v1oid sha256:be005f5f92cb583cb6a71bf87ef1471e47124a58cee9642cebc225d8870f75b3size 152123456789101112n=3;u=[0 0 0]';disp('��ʼֵx=[0 0 0]�Ľ����');[X,k]=newton(u,n);Xku=[8 8 8]';disp('��ʼֵx=[8 8 8]�Ľ����');[X,k]=newton(u,n);Xk
123version https://git-lfs.github.com/spec/v1oid sha256:f16b19c4dc581a78256db01f8234d5ebb56db3e9549e6e4f375a7861f1eac019size 4312345x0=0;n=100;[x,k]=newton1(x0,n);xk
123version https://git-lfs.github.com/spec/v1oid sha256:2c89aa2c320d98c13a2bcb7234da85f21a04d9d1650de51c18e322167959515csize 2131234567891011121314function [U,step]=newton(X,n)k=0;e=ones(n,1);while norm(e,2)>1e-6str=sprintf('X%d= %g %g %g\n',k,X);disp(str)k=k+1;A=df2(X);dX=inv(A)*f2(X);X=X-dX;e=dX;endU=X;step=k;
123version https://git-lfs.github.com/spec/v1oid sha256:0b59d13cac7d0013fd219476bad27fdbbc1c54eae7744ba03f359a2e344018ffsize 217123456789101112131415function [x,step]=newton1(x0,n)x(1)=x0;b=1;i=1;while (abs(b)>eps*x(i))x(i+1)=x(i)-f1(x(i))/df1(x(i));b=x(i+1)-x(i);i=i+1;if i>nerror('n is full');endendx=x(i);step=i;
123version https://git-lfs.github.com/spec/v1oid sha256:242285a56b83848da1b62b34261cf697d02431fefcb15018ea4c74e98bf8423csize 697123456789101112131415161718192021222324252627282930313233343536373839%Successive Over Relaxation��������function [x,sp]=sor(a,b,n,x1,w)%���e=ones(n,1);%�����Ľ�����x2=zeros(n,1);%�����Ĵ���k=0;%�����û������Ҫ��ʱ��������while norm(e,2)>1e-6%ÿ��5����ʾ�������if (rem(k,5)==0)str=sprintf('X%d= %g %g %g %g\n',k,x1);disp(str)endk=k+1;%����x2��i��for i=1:ns1=0;s2=0;if i-1>0for j=1:i-1s1=s1+a(i,j)*x2(j);endendfor j=i:ns2=s2+a(i,j)*x1(j);endx2(i)=x1(i)+w*(b(i)-s1-s2)/a(i,i);end%�����������e=x2-x1;%��x2��Ϊ�µĵ�����ֵx1=x2;end%���ص�������sp=k;%���ص���ֵx=x2;
123version https://git-lfs.github.com/spec/v1oid sha256:5f0725db12dd7f37cb2a00a3b3b5eb4752b3fd12488fff34c11f1bb7a7382dfdsize 2221234567891011121314151617181920n=1000;b=[1:n]';a1=sparse(1:n,1:n,1,n,n);a2=sparse(2:n,1:n-1,1,n,n);a=a1+a2+a2';tic;x=a\b;t1=toc;aa=full(a);tic;xx=aa\b;t2=toc;y=sum(x);yy=sum(xx);tic;eig(a);t3=toctic;eig(aa);t4=toc
123version https://git-lfs.github.com/spec/v1oid sha256:dbaf3b00127f12bd5563fa2274175fd3f4a59c7c1308adf192d0c4a333c63242size 131123function [f,g]=fun1(x)f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);g=[x(1)+x(2);1.5+x(1)*x(2)-x(1)-x(2);-x(1)*x(2)-10];
123version https://git-lfs.github.com/spec/v1oid sha256:7dab480c4dd86893771333edd6f21b813161bfe1979e962f2dce8493705e5822size 1051234x0=[-1;1];options(13)=1;%g�е�һ��Լ������Ϊ��ʽԼ��[x,options]=constr('fun1',x0,options)options(8)
123version https://git-lfs.github.com/spec/v1oid sha256:af2bdbc1924cdcedbe24fcd6e0757294543059b4ed8707389e114cc5ec50ee29size 1511234options(6)=1;%��ţ�ٷ���DFP��ʽ[x,options]=fmins('funrosen',[-1.2,2],options)y=options(8) %��������ֵ��ĺ���ֵn=options(10)%���������������
123version https://git-lfs.github.com/spec/v1oid sha256:13bbccdf960943b40f13aa5e2cd3e436e71f9727f280c3f1782fa6405ed85cc5size 19112345options(6)=1;%��ţ�ٷ���DFP��ʽoptions(7)=0;%��ϵĶ����ͺ������Ͳ�ֵ[x,options]=fminu('funrosen',[-1.2,2],options)y=options(8) %��������ֵ��ĺ���ֵn=options(10)%���������������
123version https://git-lfs.github.com/spec/v1oid sha256:a35cec4352749ab56c64073fe6e6ebdffbc356859b1fac0557a81afbbccc6c59size 6012function f=funrosen(x)f=100*(x(2)-x(1).^2).^2+(1-x(1)).^2;
123version https://git-lfs.github.com/spec/v1oid sha256:41283ec77a7a0e23b10c6adae986ab824ec36775d4f5c65f1a32123ea8de9736size 221123456789101112[x,y]=meshgrid(-2:0.1:2,-1:0.1:3);z=100*(y-x.^2).^2+(1-x).^2;figure(1);mesh(x,y,z)figure(2);contour(x,y,z,20)drawnowhold onplot(-1.2,2,'o');text(-1.2,2,'start point')plot(1,1,'o')text(1,1,'solution')
123version https://git-lfs.github.com/spec/v1oid sha256:7ee6e8ee3429787d9c44c399d6dcceb5412c432c63c521896bc8383bf5a6813dsize 781234clearx=0:0.01:1;y=-5*(1-x).^(4/5)/8+5*(1-x).^(6/5)/12+5/24;plot(x,y,'*')
123version https://git-lfs.github.com/spec/v1oid sha256:168024bc6fe588cb7536cb77bc171a3297dc187383c13360271d3e3a470f2584size 119123456789t0=0;tf=2;[t,y]=ode45('eq2',[t0 tf],[0 0]);X=1;Y=0:0.01:2;plot(X,Y,'-')hold onplot(y(:,1),y(:,2),'*')
123version https://git-lfs.github.com/spec/v1oid sha256:69340c392d937215f12de14f45d91ca4d2101cd40de4a98803da28dfd4752a4fsize 150123456789t0=0;tf=3.75;[t,y]=ode45('eq3',[t0 tf],[0 0]);T=0:0.1:2*pi;X=10+20*cos(T);Y=20+15*sin(T);plot(X,Y,'-')hold onplot(y(:,1),y(:,2),'*')
123version https://git-lfs.github.com/spec/v1oid sha256:7b263d70cb05fb410132e7b7519ebc13ff5de92515be907291183635ae266897size 149123456789t0=0;tf=200;[t,y]=ode45('eq4',[t0 tf],[0 0]);T=0:0.1:2*pi;X=10+20*cos(T);Y=20+15*sin(T);plot(X,Y,'-')hold onplot(y(:,1),y(:,2),'*')
123version https://git-lfs.github.com/spec/v1oid sha256:ef75573f07ce648d86b2f124f5376c812ee6b788ea11651b89d0dfa95382d643size 981234function dy=eq1(x,y)dy=zeros(2,1);dy(1)=y(2);dy(2)=1/5*sqrt(1+y(1)^2)/(1-x);
123version https://git-lfs.github.com/spec/v1oid sha256:cfd5a595918dbdf98b8f7ebaf18f2929207c400cbbcc7a900b480f20fcc72188size 13412345function dy=eq2(t,y)dy=zeros(2,1);dy(1)=5*(1-y(1))/sqrt((1-y(1))^2+(t-y(2))^2);dy(2)=5*(t-y(2))/sqrt((1-y(1))^2+(t-y(2))^2);
123version https://git-lfs.github.com/spec/v1oid sha256:22e146c90c0302664f9458f598d6ff941a6269c5e1b860d051f048d3e9936ca5size 20212345function dy=eq3(t,y)dy=zeros(2,1);dy(1)=20*(10+20*cos(t)-y(1))/sqrt((10+20*cos(t)-y(1))^2+(20+15*sin(t)-y(2))^2);dy(2)=20*(20+15*sin(t)-y(2))/sqrt((10+20*cos(t)-y(1))^2+(20+15*sin(t)-y(2))^2);
123version https://git-lfs.github.com/spec/v1oid sha256:6a7b025d894a92d50d7fb9fcb4b5cc6f610a81e6ce5915688872c9e7b5793e7csize 20012345function dy=eq4(t,y)dy=zeros(2,1);dy(1)=5*(10+20*cos(t)-y(1))/sqrt((10+20*cos(t)-y(1))^2+(20+15*sin(t)-y(2))^2);dy(2)=5*(20+15*sin(t)-y(2))/sqrt((10+20*cos(t)-y(1))^2+(20+15*sin(t)-y(2))^2);
matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Binary_Search.m+11-3
matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Dijkstra/MINROUTE.M+34-3
matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Dynamic_pro/DYNPROG.M+86-3
matlab数学建模算法/matlab经典算法的程序(1)/Arithmetic/Floyd/floyd.m+27-3
matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/Untitled.m+67-3
matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/test_exe.m+4-3
matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/test/test_exe_main.cpp+30-3
matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/timestwo/timestwo.c+16-3
matlab数学建模算法/matlab经典算法的程序/Arithmetic/work/timestwo/timestwo.dll
matlab数学建模算法/matlab经典算法的程序/MATLAB/tayloretc.m+13-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/biology.m+14-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/boyin.m+18-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/df1.m+3-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/df2.m+12-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/diechaos.m+24-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/erfenfa.m+19-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/exampleg.m+8-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/exampleg1.m+13-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplegs.m+10-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplejac.m+10-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/examplesor.m+22-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/f1.m+3-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/f2.m+7-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gausei.m+40-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gauss.m+32-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gauss1.m+46-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/gexian.m+14-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/jac.m+33-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainerfen.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/maingexian.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainnewton.m+12-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/mainnewton1.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/newton.m+14-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/newton1.m+15-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/sor.m+39-3
matlab数学建模算法/matlab经典算法的程序/math_exp/代数方程组的解法/sparfull.m+20-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/fun1.m+3-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funconstr.m+4-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funfmins.m+4-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funfminu.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/funrosen.m+2-3
matlab数学建模算法/matlab经典算法的程序/math_exp/优化问题实验/rosen.m+12-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase1.m+4-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase2.m+9-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase3.m+9-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/chase4.m+9-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq1.m+4-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq2.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq3.m+5-3
matlab数学建模算法/matlab经典算法的程序/math_exp/微分方程实验/eq4.m+5-3