0
votes

I am trying to run a PID controller (another model in simulink) using sim command in a matlab function block. However it takes long iteration, seems to be that the matlab function block need more time.

How to get faster result?

Here is my code in matlab function block:

function [Kpp,Kii,Kdd] = fcn(u)

coder.extrinsic('sim');
sim('ExternePID'); %call out to ExternePID model
1

1 Answers

3
votes

Don't do that, that won't work. Instead include your second Simulink model as a referenced model in your top-level Simulink model. This way, both models can run concurrently.