I try to create a matlab file that can run a simulink model.
But has problem with send data from MATLAB into the simulink model.
In the model I has Import Block that I want send my in stream of data from matlab.
My Current code of matlab is.
function result = CallSimulinkModel(modelName, timeStep, inputMatix, key)
if(timeStep<=0)
error('MATLAB:CallSimulinkModel','Timestep is lower or equal with 0');
end
endTime = max(size(inputMatix))*timeStep;
result = SubCallSimulinkModel(modelName, 0:timeStep:endTime, inputMatix, key);
%OutVector.const = inConst;
end
function [result,constants] = SubCallSimulinkModel(var_model,time_var,inputMatix, K)
var_setting = simset(...
'SrcWorkspace','current'...
);
% How to feed the sim model with the data from input matrix as Inport
% 1, Inport 2, ...?
[~,~,result] = sim(var_model, time_var, var_setting);
constants = K;
end
And the model is 
I has no problem with get the result from the simulink or set the constants K.in1
Found a working solution.
The
'LoadExternalInput', 'on', 'ExternalInput', 'D',...will tell the model to usedata from
Das time-vector and data-vector.