Trouble w/ MLGetVar and MLGetMatrix using Dataset arrays
2 次查看(过去 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!