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!