Trouble w/ MLGetVar and MLGetMatrix using Dataset arrays
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
owr
il 25 Ago 2012
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 Commenti
owr
il 30 Ago 2012
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".
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Categorical Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!