Dear Johan,
I am stuck with interp1.
I have a MILP problem solved with Gurobi in which the variable A can be represented by a piecewise linear function dependent on the variable U. A has 2 dimensions, say time T and space X. Therefore, I would like to use interp1 to interpolate the values of A at every time t and space location x. The piecewise function is always the same, and it is not dependent on either t or x, but only on U (which has to be fixed by the solver).
For example, at every t and x, my piecewise linear function is defined like:
When I try to implement the problem, I define the dimensions:
Then, the variable:
Then i define :
A=interp1( repmat(reshape(ui,[1,1,3]) ,[T,X,1] ), repmat(reshape(yi, [1,1,3]) , [T,X,1]), U, 'milp' );
The first and second arguments of interp1 have dimensions100x50x3 , while the variable U is defined as a 100x50 matrix.
I get the error:
Index exceeds matrix dimensions.
Error in sdpvar/interp1 (line 41)
out = [out;interp1(varargin{1}(i,:),varargin{2}(i,:),xij,varargin{4},varargin{5})];
Error in sdpvar/interp1 (line 21)
varargout{1} = interp1(varargin{1},varargin{2},reshape(varargin{3},[],1),varargin{4},varargin{5});
I suppose I am messing with the dimensions of my arrays. But I cannot understand how. When I solve the problem only considering the Time dimension (therefore removing the space dimension X), it works.
Namely, the arguments for interp1 are 100x3 arrays, and the variable U is a 100x1 array.
Do you have any suggestions?
Thank you
Best regards