卖逼视频免费看片|狼人就干网中文字慕|成人av影院导航|人妻少妇精品无码专区二区妖婧|亚洲丝袜视频玖玖|一区二区免费中文|日本高清无码一区|国产91无码小说|国产黄片子视频91sese日韩|免费高清无码成人网站入口

基于MATLABWebServer的遠程數(shù)值分析虛擬系統(tǒng)設計

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

廣西民族大學學報(自然科學版)

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

基于MATLAB Web Server 的遠程

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

*

黃銀娟

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

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

值分析虛擬系統(tǒng)的系統(tǒng)結構、開發(fā)技術, 并結合實例說明開發(fā)應用過程.

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

中圖分類號:TP311 文獻標識碼:A 文章編號:1673-8462(2009) 02-0099-04

0 引言

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

使用Web 瀏覽器的用戶進行動態(tài)的交互, 用戶向服務器發(fā)送數(shù)據(jù), 服務器進行計算分析, 把結果(數(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 是一個多線程的基于TCP/IP 的服務器, 它負責管理Web 應用和MA TLAB 之間的通信, 運行輸入H TM L 文檔內(nèi)的隱藏域mlm file 的值指定的M 文件. M atw eb 是m atlabserver 的一個客戶端應用, 是M AT LA B Web 的服務代理, 它利用公共網(wǎng)關接口CGI 把H T ML 的輸入數(shù)據(jù)傳送給m atlabserver. m atlab. m 是調(diào)用Web 應用要運行的M 文件. m at lab. co nf 是matlab 連接matllabserver 需要配置的文件, Web 應用必須在這里列出.

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

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

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

*

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

,

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

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

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

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

(2) 建立一個處理輸入數(shù)據(jù)和計算結果的M 文件, 對應輸入模版文件mfile_template. m;

(3) 建立一個顯示M ALTAB 計算結果的H T M L 輸出文檔, 對應輸入模版文件output_template.html 文件.

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

M y input variable 1:

其中, 表示把輸入表單fo rm 的數(shù)據(jù)發(fā)給虛擬目錄/cgi-bin 下的CGI 程序m atw eb. ex e. 表示輸入表單有一個隱藏域名為m lmfile 的變量, 現(xiàn)設其值為 my_m_file! , 對于不同的應用相應值不相同, 它是執(zhí)行計算的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 的工作原理圖

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

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

Apache 是用來架設Web Server 的軟件, 安裝完成后, 對根目錄Apache2. 2confhttpd. conf 下的httpd. conf 文件進行配置, 主要編輯以下3個參數(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/"

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

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

MAT LAB >/too lbo x/

,

2009年第2期 黃銀娟 基于M AT LA B Web Server 的遠程數(shù)值分析虛擬系統(tǒng)設計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 文件, 對于具體應用把 mfile_template ! 改為相應的文件名即可, instruct 是matw eb 程序產(chǎn)生的一個結構, 包含了與輸入H TM L 表單域的值相對應的域, 在輸入H T M L 表單中必須有一個隱藏域, 名為 mlm file ! , 其值為正在創(chuàng)建的M 文件名.

1. 4 圖形的處理

MAT LAB Web Server 通過W eb 頁面獲得輸入數(shù)據(jù), 進行計算, 生成圖形, 然后在輸出文檔頁面上顯示出來的步驟, 可作為結果需要以圖形形式返回的參照. 處理圖形的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, 用來生成唯一的文件; cd(h. mldir ) 是設置生成的圖形文件的路徑; w scleanup('m l*peaks. jpeg' , 1) 的作用是刪除此路徑下名字與. m l*peaks. jpeg(*為通配符) 類似的一小時之前生成的文件; getfield(f, ?mlid #) 函數(shù)用來獲得結構變量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

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

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

示例測試:計算的近似值. 運行過程如圖2、圖3所示. 即結果為-0. 616143, 與精確值ln0. 54=-0.

-5

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

scalars, matrices, cell arrays, graphics files,

w hich ('

2 結語

通過MA TLAB Web Server 進行在線的實時仿

,

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

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

開發(fā)[J]. 實驗室研究與探索, 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中文件參考

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

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

[參 考 文 獻]

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

社, 2001.

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

高等教育出版社, 2005.

[3]宋兆基, 等. M A TLAB 6. 5在科學計算中的應用[M ]. 北京:清華

大學出版社, 2005.

[責任編輯 蘇 琴][責任校對 黃祖賓]

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頁)

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

標簽: