Hi

My goals are:
1.Run a Simulink model using the S-function
2.Online Change reference y_ref and y_ref_e;
It’s compiled. But，some questions:
1.the Input of the S-function，I cannot match the inputs in minimal_example_ocp.m.
mabe this:
ocp.set(‘init_x’, x_traj_init);
ocp.set(‘init_u’, u_traj_init);
ocp.set(‘init_pi’, zeros(nx, N))

% change values for specific shooting node using:
%   ocp.set('field', value, optional: stage_index)
ocp.set('constr_lbx', x0, 0)

this  can update x0.
but y_ref and y_ref_e?, I cannot find how to set.
1. N = 20，nx = 4 ,nu = 1;but y_ref = zeros(100,1) y_ref_e = zeros(4,1),I cannot understand. I think y_ref = zeros(5,1)?

Thanks a lot,
gaofei

Hi,

Online Change reference y_ref and y_ref_e;

Cheers,
Jonathan

The second.

N = 20，nx = 4 ,nu = 2;y_ref = zeros(120,1) ,y_ref_e = zeros(4,1).
But,y_ref = zeros(120,1)？ I don’t know how to explain it.

Thanks a lot,
gaofei

The Simulink block input for y_ref contains the y_ref values for all stages (but the terminal one) concatenated, see:

Probably you have ny = 6, N = 20 in the problem you made the screenshot from.

Does this make sense?

Cheers!

@FreyJo. That’s right. N*ny, that’s how I understand it.
But why set this form?
I think we are not concerned about all stages.
Maybe,I just want to set the first stage.

Thanks
gaofei

This gives you the option to change y_ref at all stages, if you don’t want to change them for some stages, just set them to your default y_ref value…

thanks for the positive feedback!
I got it.