顯示具有 Matlab 標籤的文章。 顯示所有文章
顯示具有 Matlab 標籤的文章。 顯示所有文章

2013年4月22日 星期一

Matlab寫入text或Excel

寫入文字檔text


fid = fopen('filename.txt','w' ); 
fprintf(fid, '%d %d %5.2f\n', data' ); 
fclose(fid);

寫入Excel

xlswrite('filename.xlsx', data, 'sheet1', 'A1')

2011年10月8日 星期六

Matlab 寫入Excel

xlsFile = C:\output.xlsx';  % 輸出Excel檔案路徑。
[status, message] = xlswrite(xlsFile, rainfall, ‘sheet1’);  % 輸出的參數(檔案路徑, 欲輸出變數或陣列, 輸出的工作表)
dos(['start ' xlsFile]); % 輸出後開啟Excel

2010年12月9日 星期四

NETSTARS輸砂模式資料轉換工具

NETSTARS為謝慧民老師與李鴻源老師共同開發之擬似二維的沖淤模式,可模擬支流、複雜河系、陡坡、緩坡、水躍、定量流及變量流之水理及相對應底床沖淤特性,更深了解NETSTARS可詳見謝慧民老師的網站 http://www.hmhsieh.idv.tw/hmhsieh/netstars.htm
但是 NETSTARS在資料輸入上,仍需藉由資料卡輸入的方式建置,最近剛好需要跑NETSTARS模式,就藉此機會利用 Matlab與Excel建立”NETSTARS輸砂模式資料轉換工具”,目前為1.00版,此工具特色包括:
  • 使用者能利用Excel介面輸入資料,操作簡單
  • 不須額外安裝Matlab (但需安裝MCRinstaller.exe)
  • 能夠一次轉換全部的斷面資料(GR卡和NS卡)
  • 能夠一次轉換全部參數(BR與BS卡)
  • 自動在最後一筆資粒加上負號(資料結束)
  • CQ卡的功能
  • 目前僅現單一河段
下載位置:  NETSTARS輸砂模式資料轉換工具 V1.40

2010年10月13日 星期三

Matlab讀取 txt文字檔, csv, excel

path = 'C:\\';  %設定絕對路徑

%read txt
cwbdata = load(strcat(path, 'cwb_466920_2006.txt'));

%read CSV
cwbdata = csvread(strcat(path, 'cwb_466920_2006.csv'),2,0);

% Matlab 7.0以後才有的功能
%read excel
cwbdata = xlsread(strcat(path, 'cwb_466920_2006.xls'));

2010年9月28日 星期二

Matlab常用的算術函數

Matlab常用的算術函數(Arithmetic functions)


sin(x), cos(x), tan(x)


exp(x), log(x), log10(x)


- round(x) 四捨五入(Rounds a number to the nearest integer)


- ceil(x) 無條件進位(Rounds a number up to the nearest integer)


- floor(x) 無條件捨去(Rounds a number down to the nearest integer)


- fix(x) 往0的方向取最接近的整數,ex: fix(-3.3) = 3.3 (Rounds a number to the nearest integer towards zero)


- rem(x,y) x/y的餘數(The remainder left after division)


- mod(x,y) 也是餘數,但是和rem()的差別在於處理負數有差(The signed remainder left after division)


- abs(x) 絕對值(The absolute value of x)


- sign(x) 判釋正負The sign of x