Problems passing external input data into root-level Inport

7 views (last 30 days)
I have a matlab function that takes a single vector as input.
In my function which I deploy for testing I create this input vector using
u = 0.1:0.1:(stopTime/0.01);
uStruct.time = [];
uStruct.signals.dimensions = 1;
uStruct.signals.values = reshape(args.InputData,numel(args.InputData),1);
where stopTime is the value used in the later called simulink model as the sample time parameter of the Input port u.
However after compiling and deploying as a microservice I get the following error:
{"error":{"id":"Simulink:SimInput:NonDatasetRootInportError","message":"Error loading external input data into root-level Inport microserviceDemo\/u in model 'microserviceDemo'.","stack":[],"type":"matlaberror"}}* Connection #0 to host localhost left intact
That error doesn't really give me much details on what is actually going wrong, or am I missing something here? Any hints?
Thanks fo your support.

Accepted Answer

Jack
Jack on 8 Mar 2025
The error is due to the external input structure not being set up correctly. In your code, uStruct.time is left empty, which causes MATLAB to throw an error when loading data into the root-level Inport. The external input must be provided as a valid dataset that includes a proper time vector. For example, if your sample time is 0.01 and stopTime is the end of your simulation, you could do:
t = 0:0.01:stopTime; uStruct.time = t; uStruct.signals.dimensions = 1; uStruct.signals.values = reshape(args.InputData, numel(args.InputData), 1);
This ensures that the external input data has the required time field along with the corresponding signal values.
Follow me so you can message me anytime with future MATLAB questions. If this helps, please accept the answer as well.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!