Interpreting a vector as a matrix in MATLABStan

Hi,

in a Stan model I defined a data matrix ‘x’ of size (NxK):

data {
int<lower=0> N;
int<lower=0> K;
int<lower=0> S;
matrix[N, K] x;
matrix[N, S] y;
}
parameters {
vector[K] beta[S];
}
model {
for (s in 1:S)
y[:,s] ~ normal(x*beta[s], 1);
}

However, when I pass data to the corresponding StanObject ‘sm’ in Matlab,

data = struct(‘N’,n,‘K’,k,‘S’,s,‘x’,X,‘y’,y);
map = sm.optimizing(‘data’,data);

Stan hangs up with the following warning: ‘Warning: Stan seems to have exited badly.’ But this is only the case when X has only one column. Otherwise everything works fine.

It seems as if the data file created in an intermediate step by MatlabStan (called temp.data.R) is fed with two types of R containers, depending on the dimensionality of X.
When X is (NxK) for K=1, then MatlabStan creates the following line in ‘temp.data.R’:
x <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)

whereas

x <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 5.263158e-02, 1.052632e-01, 1.578947e-01, 2.105263e-01, 2.631579e-01, 3.157895e-01, 3.684211e-01, 4.210526e-01, 4.736842e-01, 5.263158e-01, 5.789474e-01, 6.315789e-01, 6.842105e-01, 7.368421e-01, 7.894737e-01, 8.421053e-01, 8.947368e-01, 9.473684e-01, 1), .Dim = c(20,2))

would be created for K=2 (and N=20 in this specific example).

I debugged the MatlabStan code up to the point where the data file is created and manually replaced

x <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)

with

x <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(20,1))

for the K=1 case. That worked!
Is there a direct way to tell MatlabStan to interpret a matrix of size (Nx1) as a Stan matrix instead of a Stan vector?

Operating System: Windows 10
Interface Version: 2.15.1.0