使用MATLAB对资料库进行修改另一种方法-MIRLab
範例-5 (II) 使用了一個筆者開發的函數 struct2html.m,可以將結構陣列的內容呈現至網頁,以便觀看 範例13-5: db2struct02.m DSN = dsnScore01; % 設定資料來源名稱(指到 score01.mdb) logintimeout(5); % 設定嘗試連結資料庫的時間 conn = database(DSN, , ); % 連結資料庫 sql = select * from score order by studentID; % 設定 SQL 命令 cursor = exec(conn, sql); % 執行 SQL 命令,並傳回 cursor 物件 cursor = fetch(cursor); % 經由 cursor 物件,抓取全部資料 範例-5 (III) score = cursor.data; % 將資料傳至 MATLAB 變數 score temp = columnnames(cursor); %資料庫欄位名稱 eval([fieldNames = {, temp, };]); % 將欄位名稱指定到 fieldNames 變數 score2 = cell2struct(score, fieldNames, 2); %轉成結構陣列 score2 close(cursor);
原创力文档

文档评论(0)