Azzera filtri
Azzera filtri

Call a custom C-mex from MATLAB Function block (cvxgen)

2 visualizzazioni (ultimi 30 giorni)
Hi all,
I'm using cvxgen and I'd like to build a MATLAB function block in a Simulink model to call my MPC controller. However, it seems like "Code generation does not support cell arrays in structure fields". I want to know if somebody can help me resolve this issue. cvxgen defines my reference signal as params.yr which is a cell array in a structure
if true
% code
end
function [vars_u_0, vars_x_0, optval, gap, steps, converged]=myfcn(~)
%#codegen
params.A = 0.9333;
params.B = 0.1;
params.C = 0.8889;
params.D = -0.33;
params.Q = 100;
params.R = 1;
params.x_0 = 0.1;
params.u_max = 63.5;
params.S = 1000;
params.yr_0 = 1;
params.x_0 = 1;
params.yr = cell(10,1);
for i=1:10
params.yr{i}=rand(1)*10;
end
coder.extrinsic('csolve_mex');
status.optval = 0;
status.gap = 0;
status.steps = 0;
status.converged = 0;
vars.u_0 = zeros(1, 1);
vars.x_0 = zeros(1, 1);
[vars, status]=csolve_mex(params);
vars_u_0 = vars.u_0;
vars_x_1 = vars.x_1;
optval = status.optval;
gap = status.gap;
steps = status.steps;
converged = status.converged;
Thank you so much for your time. I really appreciate that!

Risposte (0)

Categorie

Scopri di più su Code Generation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by