lib/matlab/driver/native/conversions.rb in matlab-ruby-2.0.2 vs lib/matlab/driver/native/conversions.rb in matlab-ruby-2.0.3

- old
+ new

@@ -48,11 +48,14 @@ end class Array # Converts the array into a 1 Dimensional MATLAB numeric or cell matrix def to_matlab - if all? { |value| value.kind_of?(Numeric) || value.nil? } + if empty? + matrix = Matlab::Matrix.new(0, 0) + matrix.to_matlab + elsif all? { |value| value.kind_of?(Numeric) || value.nil? } matrix = Matlab::Matrix.new(size, 1) each_with_index do |value, index| matrix[index, 0] = value end @@ -229,10 +232,12 @@ Matlab::CellMatrix.from_matlab(self) when mxIsChar(self) mxArrayToString(self) when mxIsLogical(self) mxIsLogicalScalarTrue(self) - when (mxGetM(self) > 1 || mxGetN(self) > 1) || (mxGetM(self) == 0 && mxGetN(self) == 0) + when (mxGetM(self) == 0 && mxGetN(self) == 0) + [] + when (mxGetM(self) > 1 || mxGetN(self) > 1) Matlab::Matrix.from_matlab(self) when mxIsDouble(self) mxGetScalar(self) when mxIsEmpty(self) nil \ No newline at end of file