国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

基于MATLABWebServer的遠(yuǎn)程數(shù)值分析虛擬系統(tǒng)設(shè)計(jì)

廣西民族大學(xué)學(xué)報(bào)(自然科學(xué)版)第15卷第2期 JOURNAL OF GUANGXI UNIVERSITY FOR NATIONALITIES Vol. 15No. 22009年5月(Na

廣西民族大學(xué)學(xué)報(bào)(自然科學(xué)版)

第15卷第2期 JOURNAL OF GUANGXI UNIVERSITY FOR NATIONALITIES Vol. 15No. 22009年5月(Natural Science Edition) May 2009

基于MATLAB Web Server 的遠(yuǎn)程

數(shù)值分析虛擬系統(tǒng)設(shè)計(jì)

*

黃銀娟

(廣西民族大學(xué)數(shù)學(xué)與計(jì)算機(jī)科學(xué)學(xué)院, 廣西南寧 530006)

摘 要:在介紹MATLAB Web Server 的工作原理基礎(chǔ)上, 給出開(kāi)發(fā)基于MATLAB Web Server 的遠(yuǎn)程數(shù)

值分析虛擬系統(tǒng)的系統(tǒng)結(jié)構(gòu)、開(kāi)發(fā)技術(shù), 并結(jié)合實(shí)例說(shuō)明開(kāi)發(fā)應(yīng)用過(guò)程.

關(guān)鍵詞:MATLAB Web Server; 虛擬系統(tǒng); 數(shù)值分析

中圖分類號(hào):TP311 文獻(xiàn)標(biāo)識(shí)碼:A 文章編號(hào):1673-8462(2009) 02-0099-04

0 引言

數(shù)值分析作為工程計(jì)算和科學(xué)計(jì)算的一門基礎(chǔ)課程日益受到人們的重視, 已成為各高校計(jì)算和信息專業(yè)學(xué)生的必修課, 同時(shí)也成為工科碩士研究生學(xué)位公共必修課. M AT LAB 是目前最流行的科學(xué)計(jì)算語(yǔ)言之一, M AT LAB 6. 0以后的版本提供了Web Serv er 組件, 為M ALTAB 的Web 應(yīng)用搭建了橋梁, 借助它可實(shí)現(xiàn)M ATLAB 的B/S 模式系統(tǒng)的開(kāi)發(fā). 在教學(xué)上, 利用它建立遠(yuǎn)程數(shù)值分析虛擬系統(tǒng), 避免了安裝M ATLAB 軟件和煩瑣的程序輸入與調(diào)試的局限性, 能隨時(shí)隨地的利用Internet 方便快捷地進(jìn)行遠(yuǎn)程交互式仿真虛擬實(shí)驗(yàn), 給教學(xué)、實(shí)驗(yàn)和學(xué)習(xí)帶來(lái)了很大的方便.

使用Web 瀏覽器的用戶進(jìn)行動(dòng)態(tài)的交互, 用戶向服務(wù)器發(fā)送數(shù)據(jù), 服務(wù)器進(jìn)行計(jì)算分析, 把結(jié)果(數(shù)據(jù)或圖片) 返回到客戶的瀏覽器上顯示. 1. 1 MAT LAB Web Server 工作原理

M AT LAB W eb Serv er 組件包括m atlabserver 、m atw eb 、matw eb. m 和matw eb. co nf. 其中, matlab serv er 是一個(gè)多線程的基于TCP/IP 的服務(wù)器, 它負(fù)責(zé)管理Web 應(yīng)用和MA TLAB 之間的通信, 運(yùn)行輸入H TM L 文檔內(nèi)的隱藏域mlm file 的值指定的M 文件. M atw eb 是m atlabserver 的一個(gè)客戶端應(yīng)用, 是M AT LA B Web 的服務(wù)代理, 它利用公共網(wǎng)關(guān)接口CGI 把H T ML 的輸入數(shù)據(jù)傳送給m atlabserver. m atlab. m 是調(diào)用Web 應(yīng)用要運(yùn)行的M 文件. m at lab. co nf 是matlab 連接matllabserver 需要配置的文件, Web 應(yīng)用必須在這里列出.

M AT LAB 的網(wǎng)絡(luò)結(jié)構(gòu)模型主要由3個(gè)部分組成:客戶端用戶、MA TLAB Web 服務(wù)代理、MAT LAB Web 服務(wù)器. 其工作原理如圖1所示:

1 系統(tǒng)實(shí)現(xiàn)

基于M ATLAB Web Server 的遠(yuǎn)程數(shù)值分析系統(tǒng)的構(gòu)建以Window s 2003Ser ver 為平臺(tái), 基于A pache H T TP Server 2. 2. 4Web 服務(wù)器以及M AT LAB R2006a 配置M AT LAB Web 服務(wù)器, 架設(shè)在數(shù)值分析的實(shí)例上得以實(shí)現(xiàn). M ATLAB Web 服務(wù)器可

*

收稿日期:2009 03 10. 作者簡(jiǎn)介:黃銀娟(1976 ) , 女, 廣西南寧人, 廣西民族大學(xué)數(shù)學(xué)與計(jì)算機(jī)科學(xué)學(xué)院教師, 研究方向:教育技術(shù).

,

廣西民族大學(xué)學(xué)報(bào)(自然科學(xué)版) 2009年5月 第15卷

(3) 拷貝所有需要的H TM L 文件到httpd 能到達(dá)的目錄.

1. 3 MAT LAB Web Server 應(yīng)用程序開(kāi)發(fā)模版文件M AT LAB Web Server 應(yīng)用包括M 文件、H T M L 和圖形, 進(jìn)行開(kāi)發(fā)只需要基本的H T M L 知識(shí), 創(chuàng)建M AT LA B Web Server 應(yīng)用程序主要包括以下三個(gè)步驟:

(1) 建立一個(gè)向M AT LAB 提交數(shù)據(jù)的H T ML 輸入文檔, 對(duì)應(yīng)輸入模版文件input_template.html;

(2) 建立一個(gè)處理輸入數(shù)據(jù)和計(jì)算結(jié)果的M 文件, 對(duì)應(yīng)輸入模版文件mfile_template. m;

(3) 建立一個(gè)顯示M ALTAB 計(jì)算結(jié)果的H T M L 輸出文檔, 對(duì)應(yīng)輸入模版文件output_template.html 文件.

這3個(gè)模版文件提供了開(kāi)發(fā)的框架代碼, 利用模版, 可直接方便地建立應(yīng)用程序. 輸入模版文件input _template.htm l 此頁(yè)面主要用來(lái)向MAT LAB 提交數(shù)據(jù), 主要代碼如下:

M y input variable 1:

其中, 表示把輸入表單fo rm 的數(shù)據(jù)發(fā)給虛擬目錄/cgi-bin 下的CGI 程序m atw eb. ex e. 表示輸入表單有一個(gè)隱藏域名為m lmfile 的變量, 現(xiàn)設(shè)其值為 my_m_file! , 對(duì)于不同的應(yīng)用相應(yīng)值不相同, 它是執(zhí)行計(jì)算的M 文件名.

輸出模版文件mfile_template.m

functio n r etstr =mfile_template(instruct, out file)

r etstr =char(' ) ;

cd(instruct. mldir) ;

m y_input _variable _1=instruct. my _input _v ar iable_1;

M AT LAB com putations, etc. ;

圖1 M A T L AB Web Server 的工作原理圖

客戶端瀏覽器通過(guò)TCP/IP 協(xié)議向H T TP 服務(wù)器發(fā)送服務(wù)請(qǐng)求, M ATLAB Web 服務(wù)代理負(fù)責(zé)解釋從H T TP 服務(wù)器發(fā)送過(guò)來(lái)的請(qǐng)求, 如果是MA TLAB Web 的服務(wù)請(qǐng)求, 則把它定向到MAT LAB 服務(wù)器進(jìn)行處理, 否則由標(biāo)準(zhǔn)的Web 服務(wù)器進(jìn)行處理; 數(shù)據(jù)通過(guò)內(nèi)部協(xié)議傳送到MAT LAB 服務(wù)器后, matlab server 調(diào)用相應(yīng)的M ALTAB 程序(M 文件) 到MAT LAB 進(jìn)行計(jì)算, 最后, 把運(yùn)行結(jié)果以數(shù)據(jù)或圖片形式返回到H T TP 服務(wù)器, 再由H T T P 服務(wù)器將結(jié)果輸出到客戶端.

1. 2 系統(tǒng)服務(wù)器的參數(shù)配置

Apache 是用來(lái)架設(shè)Web Server 的軟件, 安裝完成后, 對(duì)根目錄Apache2. 2confhttpd. conf 下的httpd. conf 文件進(jìn)行配置, 主要編輯以下3個(gè)參數(shù):

(1) Do cumentRoot " /too lbo x/w ebserver/w sdemos"

(2) Scr iptAlias /cgi-bin/" /to olbox/w ebserver/w sdemo s/"

(3) Alias /ico ns/"

如果沒(méi)有權(quán)限建立或修改這些別名, 則必須將:(1) 拷貝matw eb. exe 目錄到別名/cg i-bin/所對(duì)應(yīng)的目錄下;

(2) 拷貝matweb. conf 到別名/cg i-bin/所對(duì)應(yīng)的目錄下;

MAT LAB >/too lbo x/

,

2009年第2期 黃銀娟 基于M AT LA B Web Server 的遠(yuǎn)程數(shù)值分析虛擬系統(tǒng)設(shè)計(jì)outstruct. m y _o utput _variable _1=MAT LAB com putations cr eating .. . etc. ;

templatefile =PLA TE. H T M L>' ) ;

其中, function r etstr =m file _tem plate (in struct, o utfile) 表明此M 文件為函數(shù)M 文件, 對(duì)于具體應(yīng)用把 mfile_template ! 改為相應(yīng)的文件名即可, instruct 是matw eb 程序產(chǎn)生的一個(gè)結(jié)構(gòu), 包含了與輸入H TM L 表單域的值相對(duì)應(yīng)的域, 在輸入H T M L 表單中必須有一個(gè)隱藏域, 名為 mlm file ! , 其值為正在創(chuàng)建的M 文件名.

1. 4 圖形的處理

MAT LAB Web Server 通過(guò)W eb 頁(yè)面獲得輸入數(shù)據(jù), 進(jìn)行計(jì)算, 生成圖形, 然后在輸出文檔頁(yè)面上顯示出來(lái)的步驟, 可作為結(jié)果需要以圖形形式返回的參照. 處理圖形的w ebpeaks. m 文件中的主要代碼為:

function rs =w ebpeaks(h) mlid =getfield(h, ' m lid') ; cd(h. mldir ) ;

w scleanup(' m l*peaks. jpeg ' , 1) ; draw no w ;

s. GraphFileName =sprintf (' speaks. jpeg ' , mlid) ;

w sprintjpeg(f, s. Gr aphFileNam e) ;

s. GraphFileNam e =sprintf(' /icons/speaks. jpeg' , mlid) ;

其中, mlid =g etfield(h, 'mlid') 的作用是獲得唯一的ID, 用來(lái)生成唯一的文件; cd(h. mldir ) 是設(shè)置生成的圖形文件的路徑; w scleanup('m l*peaks. jpeg' , 1) 的作用是刪除此路徑下名字與. m l*peaks. jpeg(*為通配符) 類似的一小時(shí)之前生成的文件; getfield(f, ?mlid #) 函數(shù)用來(lái)獲得結(jié)構(gòu)變量h 中名為mlid 的變量的值. s. Gr aphFileName =sprintf(' /i cons/speaks. jpeg ' , m lid) 的作用為生成文件名. Wsprintjpeg (fk, s. GraphFileN am e) 的作用是把f 圖片框中的圖形存到以s. Gr aphFileName 的值為文件名的文件里. spr intjpeg 首先利用M ATLAB 的帶-djpeg 參數(shù)的print 命令生成JPEG 文件, 如果失敗,

圖3 L ag range 插值法輸出界面圖2 L ag range

插值法輸入界面

Mo re

就生成一個(gè)臨時(shí)的PCX 文件, 再調(diào)用imw rite 寫到一個(gè)JPEG 文件里. 1. 5 數(shù)值分析實(shí)例

Lagr ange 插值是一種普遍應(yīng)用的插值方法, 它要求在插值節(jié)點(diǎn)上, 插值函數(shù)和原函數(shù)的值相等. 服務(wù)器端的Lagrange 插值法M 文件的主要功能是接收從客戶端發(fā)送過(guò)來(lái)的數(shù)據(jù)參數(shù), 然后進(jìn)行數(shù)據(jù)處理并計(jì)算, 最后將計(jì)算結(jié)果輸出. 客戶端要傳送的參數(shù)數(shù)據(jù)有已知插值點(diǎn)的X 、Y 坐標(biāo)與及插值點(diǎn)的坐標(biāo). 在模板M 文件中嵌入Lagrange 插值法的MAT LAB 程序, 然后加入繪圖、圖形輸出語(yǔ)句, M 文件處理得出的結(jié)果是Lagr ange 多項(xiàng)式在x =x 0處的值, 具體代碼略.

示例測(cè)試:計(jì)算的近似值. 運(yùn)行過(guò)程如圖2、圖3所示. 即結(jié)果為-0. 616143, 與精確值ln0. 54=-0.

-5

6161861394238170比較接近, 誤差率為7 0?10.

scalars, matrices, cell arrays, graphics files,

w hich ('

2 結(jié)語(yǔ)

通過(guò)MA TLAB Web Server 進(jìn)行在線的實(shí)時(shí)仿

,

廣西民族大學(xué)學(xué)報(bào)(自然科學(xué)版) 2009年5月 第15卷

[4]劉春鳳, 等. 實(shí)用數(shù)值分析教程[M ]. 北京:冶金工業(yè)出版社, 2006. [5]辛?xí)喳? 李世銀, 等. 基于M ATLAB W eb S erver 的遠(yuǎn)程仿真系統(tǒng)

開(kāi)發(fā)[J]. 實(shí)驗(yàn)室研究與探索, 2005, (24)

[6]黃斯偉, 等. H TM L 完全使用詳解[M ]. 北京:人民郵電出版社,

2006.

[7]T he M athW orks –M ATLAB W eb Server [EB/OL ]. http://

w w w. mathw orks. com/access/h elpdesk _r13/h elp/toolb ox/w eb server/w ebserver. html.

[8]在M icrosoft Win dow s 中使用Apach e –Apache 2. 2中文件參考

手冊(cè)[EB/OL]. http://doc. chin ahtml. com/M anual/ApacheM anu al/platform/w indow s. h tm l.

真, 用戶只需通過(guò)交互式網(wǎng)頁(yè)就可進(jìn)行MA TLAB 仿真, 使用戶可以而不必在客戶端安裝MAT LAB 軟件而實(shí)現(xiàn)MA TLAB 應(yīng)用. 同時(shí), 用戶也不必知道太多有關(guān)MAT LAB 編程的知識(shí), 簡(jiǎn)化了仿真軟件的開(kāi)發(fā)難度和降低了仿真對(duì)用戶端系統(tǒng)環(huán)境的要求, 非常適用于網(wǎng)絡(luò)教學(xué)和遠(yuǎn)程實(shí)驗(yàn), 同時(shí)提高了效率.

[參 考 文 獻(xiàn)]

[1]馬興義, 等. M AT LAB 6應(yīng)用開(kāi)發(fā)指南[M ]. 北京:機(jī)械工業(yè)出版

社, 2001.

[2]王能超. 計(jì)算方法&&&算法設(shè)計(jì)及其M ATLAB 實(shí)現(xiàn)[M ]. 北京:

高等教育出版社, 2005.

[3]宋兆基, 等. M A TLAB 6. 5在科學(xué)計(jì)算中的應(yīng)用[M ]. 北京:清華

大學(xué)出版社, 2005.

[責(zé)任編輯 蘇 琴][責(zé)任校對(duì) 黃祖賓]

Remote Numerical Analysis Virtual System Based on MATLAB Web Server

H U A N G Y in juan

(Collegeof M athematics and Comp uter Science, Guangx i Univer sity f or

N ationalities, N anning 530006, China)

Abstract:M AT LAB W eb Server at the intro duction of w ork on basic principles, give System architec

ture, the development o f technolog y o f the numerical analysis virtual sy stem based o n the M ATLAB Web Serv er, combined w ith the process of development and application examples.

Key Words:M ATLAB Web Server; V ir tual Sy stem ; N um erical Analysis

(上接第88頁(yè))

The ARIMA Model of Overseas Tourism Source

in HeBei and its Application

T A N G Shi xing , K E Feng qin

1

2

(1.Dep ar tment of M athem atic and P hy sics , Chengde Petr oleum College, Chengde 067000, China ; 2.Dep artment of A utomotive Engineer ing , Cheng de Petroleum College, Cheng de 067000, China)

Abstract:Introducing analytical method of ARIM A m odel in ov erseas tourism so urce. Accor ding to

the number of ov erseas tourist from 1989to 2006of H ebei pr ovince build the ARIM A (0, 2, 1) predictio n model, and for ecast the number o f o verseas v isito rs fro m 2007to 2009. The relativ e erro r w as o nly 2. 8to com pare predictiv e data to the actual number of overseas tourist data in 2007, and the application of the mo d el w as proved a viable and effective in sho rt-ter m prediction o f overseas tourism data.

Key Words:ov erseas tourism source ; ARIM A m odel ; predictive model

標(biāo)簽: