Trouble w/ MLGetVar and MLGetMatrix using Dataset arrays
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 54 X 10 dataset set array that I can't get out of MatLab and into MS Excel/VBA. Using MLGetVar the following code breaks after the first iteration of 'y'. Hovering over the variable is shows as empty.
TEMPRowSize = 54
TEMPColSize = 10
MLGetVar "FirstPageTEMP", FirstPageTEMP
For x = 1 To TEMPRowSize
For y = 1 To TEMPColSize
.Cells(x, y).value = FirstPageTEMP(x, y)
Next y
Next x
End With
Using MLGetMatrix returns no values to my worksheet at all.
MLGetMatrix "FirstPageTEMP", ActiveSheet.Range("A1").Address
MatlabRequest
Any ideas? Please help jason
0 件のコメント
採用された回答
owr
2012 年 8 月 25 日
I highly doubt that MlGetVar/Matrix support dataset arrays which are in the Statistics Toolbox. It would be nice if they did, even better if dataset arrays were moved to core MATLAB. I think you're going to need to write your dataset arrays to MATLAB primitives and use these instead.
2 件のコメント
owr
2012 年 8 月 30 日
I think thats probably the best approach. 2012A has a method called "dataset2cell", if you have access to a newer version maybe that would work? "cellstr" only works if all the columns are atrings of some type, wont work with numeric data.
Otherwise, you can write a method like this yourself. Its not "elegent" but likely what similar built in MATLAB functions are doing.
If your dataset array is named "ds", grab the column names using:
cn = get(ds,'VarNames')
and then loop over each column using this type of syntax:
ds.(cn{i}) (i is your loop index)
You can test each column's type using "iscell" or "isnumeric", etc. and convert then using something like "num2cell" or "mat2cell".
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Categorical Arrays についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!