[問題]只讀取txt檔中的數據成矩陣

看板MATLAB作者 (將將將將)時間14年前 (2011/12/15 19:29), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
各位大大們好,小弟現在有一個txt檔如下 檔名:example.txt 內容: max,min PERFORM DRIFT TIME HISTORIES Structure = Strcture 1 Analysis Series = PEER 2-1 IDA Load Case =, [3] = [2] + PEER 2-1 Sa = 0.1g Column 1 =, time (sec) Column, 2, = drift no., 6, name =, 1st Column, 3, = drift no., 7, name =, 2nd Column, 4, = drift no., 8, name =, 3rd Column, 5, = drift no., 9, name =, 4th Maximum,0.0014368,0.0017769,0.0015642,0.0017663 Minimum,-0.001507,-0.001819,-0.0021522,-0.001507 我要的是最後兩行的數字然後轉成矩陣 0.0014368 0.0017769 0.0015642 0.0017663 -0.001507 -0.001819 -0.0021522 -0.001507 這樣的矩陣而已!不好意思有點趕,爬文了一些也看不太懂^^" 拜託了!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.13.114

12/15 20:34, , 1F
我的作法是 用fgetl逐行讀到最後兩行 再取出你需要的數字
12/15 20:34, 1F

12/15 20:35, , 2F
記得讀完要把字串轉成數值
12/15 20:35, 2F
文章代碼(AID): #1EwTejNe (MATLAB)