您可能有興趣構建虛假的數據庫,直到服務器啓動。以下是一些代碼及其相關結果。
您可以通過在工作區瀏覽器中雙擊每個變量或在編輯器窗口中鍵入變量的名稱來評估每個變量的內容,方法是將鼠標指向每個變量(您有來設置偏好,編輯,顯示,使在編輯模式下數據提示)
%fake database
field1 = 'date'; value1 = datestr(repmat(now, 5,1));
field2 = 'cola'; value2 = rand(5,1);
field3 = 'colb'; value3 = zeros(5,1);
field4 = 'colc'; value4 = ones(5,1);
%create a temp structure
temp = struct(field1,value1,field2,value2,field3,value3,field4,value4);
以下代碼
names = fieldnames(temp);
names = names(2:end);
給出:
名稱=
'cola'
'colb'
'colc'
cells = struct2cell(temp);
orgTS = cell2mat(cells(2:end)');
給出
orgTS =
0.7866 0 1.0000
0.5043 0 1.0000
0.4850 0 1.0000
0.8388 0 1.0000
0.0859 0 1.0000
effectiveDate = temp.date
給
effectiveDate =
04-Oct-2013 00:24:38
04-Oct-2013 00:24:38
04-Oct-2013 00:24:38
04-Oct-2013 00:24:38
04-Oct-2013 00:24:38