?? mathmodl.m
字號:
clc;echo on;
%##########################################################################
% 本工具箱主要為學習數學建模和參加中國大學生數學建模競賽的同學而制作。匯集了
% 數學建模常用的最優化、微分方程、數據擬合、統計等方面的計算工具,包括我們自
% 編的補充工具。工具箱還匯集了96-99中國大學生數學建模競賽題解MATLAB程序。本
% 工具箱也可供使用MATLAB作數值計算的學生、教師和科技人員參考。
%##########################################################################
echo off
more(25)
echo on
pause % Strike any key to continue (Note: use Ctrl-C to abort)
type contents %使用回車鍵看下行
more off
pause % Strike any key to continue (Note: use Ctrl-C to abort)
clc
%##########################################################################
% 例一:使用中文幫助
%##########################################################################
%(1)其實使用中文幫助和通常使用英文幫助是一樣的,例如你想知道 plot 的用法,用命令
pause % Strike any key to continue (Note: use Ctrl-C to abort)
help plot
%以上最前幾行是中文幫助,緊隨其后的是原先的英文幫助。
pause % Strike any key to continue (Note: use Ctrl-C to abort)
%(2)除少數英文幫助已配例題外,中文幫助大多都配有中文例題,例如樣條插值 spline
pause % Strike any key to continue (Note: use Ctrl-C to abort)
help spline
%現在使用
pause % Strike any key to continue (Note: use Ctrl-C to abort)
clear;close;
x=[1 2 4 5];y=[1 3 4 2];
p=spline(x,y);
xi=1:0.1:5;yi=ppval(p,xi);
plot(x,y,'o',xi,yi,'k');
title('not-a-knot SPLINE');
[b,c]=unmkpp(p)
%(3)中文幫助只列出了最常用的使用格式,完全格式請參考英文幫助。
pause % Strike any key to continue (Note: use Ctrl-C to abort)
close;clc
%##########################################################################
% 例二:學習最優化方法
%##########################################################################
% MATLAB優化工具箱有一個學習最優化計算的教程。使用tutdemo啟動(這里省略)。
% 如果你對其中英文命令不太懂,請使用相應的中文幫助
%
% 例如下列非線性約束優化方法 constr
pause % Strike any key to continue (Note: use Ctrl-C to abort)
help constr
% 根據幫助,現在請你先用MATLAB編輯器將模型函數寫成M函數optfun2.m
% function [f,g]=optfun2(x)
% f=-x(1)*x(2)*x(3)
% g(1)=x(1)-x(2)-10;
% g(2)=x(1)-x(2)-2*x(3);
% g(3)=x(1)+2*x(2)+2*x(3)-72
% 然后在MATLAB命令窗口求解
pause % Strike any key to continue (Note: use Ctrl-C to abort)
x0=[10,10,10];
options(13)=1;
[x,options]=constr('optfun2',x0,options,[-inf,10,-inf]',[inf,20,inf]);
x %最大值點
-options(8) %目標函數最大值
pause % Strike any key to continue (Note: use Ctrl-C to abort)
clc
%##########################################################################
% 例三:自編工具
%##########################################################################
% 我們自編了許多MATLAB欠缺的數學建模工具。如重積分、隨機模擬、離散優化等。例如
% 下列最小生成樹kruskal算法使用了CMEX技術
pause % Strike any key to continue (Note: use Ctrl-C to abort)
help kruskal
clear;map=[1 2 30;2 4 5;2 5 50;3 2 6;4 3 1;1 4 20;1 5 30]
[out,len]=kruskal(map)
pause % Strike any key to continue (Note: use Ctrl-C to abort)
close;clc;
%##########################################################################
% 例四:數學建模競賽題解程序
%##########################################################################
%我們編寫了96—99數學建模競賽一些優秀解答的MATLAB程序
pause % Strike any key to continue (Note: use Ctrl-C to abort)
type jm98a1
echo off
jm98a1
echo on
pause % Strike any key to continue (Note: use Ctrl-C to abort)
type jm98a2
echo off
jm98a2
echo on
pause % Strike any key to continue (Note: use Ctrl-C to abort)
type jm98a1
echo off
jm98a3
echo on
pause % Strike any key to continue (Note: use Ctrl-C to abort)
clc
%##########################################################################
% 愿我們的工作能對您有所幫助。
% 歡迎交流,請多提意見。
% Email: ljhu@dhu.edu.cn
% 參加制作:胡良劍、丁曉東、馬裕、陸鎖軍、李偉鐘
%##########################################################################
echo off
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -