MATLAB: Error with extract results from tomRun

matlab codersimulink

i have an error with the function tomrun.I am running in the simulink in an embedeed blocks.This is the code
Wnl = 1;
dw = zeros (2,10);
dw = [Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl;
Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl];
Prob = qpAssign(FF, S, Alpha, b_L(1:7), b_U(1:7), [], [], [], [],...
[], [], [], [], [], [], []);
Result = tomRun('qpSolve', Prob, 1)
eml.extrinsic('extractResult');
dwp = extractResult(Result)
dwopt = [0 0];
dwopt = dw
wstart = [0.98 0.99];
Wnlop = wstart + dwopt ;
%%function extract results
function dww = extractResult(Result)
dww = Result.x_k;
end
And i am taking this error Embedded MATLAB Interface Error: Size mismatch for MATLAB expression 'dwp'. Expected = 1×2 Actual = 2×1 Block load_sharing (#19) While executing: none.
I tried to change the size but again i'm taking the same error,can someone help me?

Best Answer

This is the code in an embedeed block
function Wnlop = loadsharing_Linearization_MPC(Wnlop3)%,e)
Wnl = 1;
dw = zeros (2,10);
dw = [Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl;
Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl Wnl];
FF = [ 945.8209 868.6367
868.6367 797.7697];
S = [ -273.5275
-251.1619];
Alpha = [ 0 0
7.9634 7.3155
0 0
0.1303 0.1307
7.9634 7.3155
-7.9634 -7.3155
0 0];
b_L = [29.1083 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583
29.1083 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583
-Inf 29.1540 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561
-Inf 29.1561 27.1562 -0.0366 14.0596 14.0597 14.0597 -14.0597 0 0
57.3266 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166
-Inf 0 0 0 0 0 0 0 0 0
28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583];
b_U =[ 29.2083 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583
29.2083 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583
31.6583 29.1540 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561 29.1561
31.4061 29.1561 27.1562 -0.0366 14.0596 14.0597 14.0597 -14.0597 0 0
Inf 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166 56.3166
0.9700 0 0 0 0 0 0 0 0 0
Inf 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583 28.1583];
eml.extrinsic('extractResult');
eml.extrinsic('qpAssign','tomRun');
Prob = qpAssign(FF, S, Alpha, b_L(1:7), b_U(1:7), [], [], [], [],...
[], [], [], [], [], [], []);
Result = tomRun('qpSolve', Prob, 1)
eml.extrinsic('extractResult');
dwp = extractResult(Result)
dwopt = [0 0];
dwopt = dw
wstart = [0.98 0.99]
Wnlop = wstart + dwopt ;