看板 MATLAB 關於我們 聯絡資訊
第一次在這發言,請多多指教...>< 我是想要建一個 structure array, 而且想要一開始就設定好他有多大, 可是看到網路上的範例都是依序把資料加上去, 雖然這樣也是可以寫得出來啦... 可是就覺得不太習慣, 覺得在一開始 create variable 的時候就定義好它大小會比較舒服...>< 例如,我已經知道我有 100 個學生, 每個學生都有一個名字、和許多個 email (每個學生有不同數目的 email) 目前都是用 for loop 寫: for i = 1 : 100 student(i).name = '他的名字'; student(i).email = [email1 email2 ...] end 想問問大家有沒有可以在一開始定義 student 是 100 個的寫法? 謝謝大家>< -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.99 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1425543547.A.840.html
celestialgod: create cell then using cell2struct 03/05 17:05
celestialgod: 詳細可以參考 cell2struct的manual 03/05 17:05
headache: [st(1:100)] = deal(struct('name',[],'email',[])); 03/09 13:54
headache: 是要像這樣的嗎 03/09 13:54