フィルターのクリア

Problen with using varsize

2 ビュー (過去 30 日間)
Grek Vardugin
Grek Vardugin 2018 年 11 月 4 日
回答済み: Grek Vardugin 2018 年 11 月 12 日
Hello! I need some problems with using function varsize. This is my code:
lambda = struct('lower', 0, 'upper', 0, 'eqlin', 0, 'ineqlin', 0);
coder.varsize('lambda.lower', [1,inf]);
coder.varsize('lambda.upper', [1,inf]);
coder.varsize('lambda.eqlin', [1,inf]);
coder.varsize('lambda.ineqlin', [1,inf]);
[xopt,zmin,exitflag,output2,lambda] = linprog(C1,A,B,[],[],LB1,[],[],options);
fprintf(1,Out1,xopt,zmin);
fprintf(1,'ExitFlag= %d\nIterats= %d\n',exitflag,output2.iterations);
fprintf(1,'Algorithm - %s\n',output2.algorithm);
fprintf('Dual problem\n');
fprintf(1,'y1 = %1.5f\ny2 = %1.5f\ny3 = %1.5f\n', lambda.ineqlin(1),lambda.ineqlin(2), lambda.ineqlin(3));
And I see this error:
MATLAB expression 'lambda.lower' is not of the correct size: expected
[1x1] found [3x1].
I try to compile MEX-function with codegen. What's wrong?

採用された回答

Grek Vardugin
Grek Vardugin 2018 年 11 月 12 日
My solution.
if isempty(Aeq)
valueAeq = [];
else
valueAeq = ones(size(Aeq,1), 1);
end
if isempty(A)
valueA = [];
else
valueA = ones(size(A,1), 1);
string1 = [ ' ',num2str(A(1,1)),'x1)'];
end
lambda = struct('lower', ones(size(C,2),1), 'upper', ones(size(C,2),1), 'eqlin', valueAeq, 'ineqlin', valueA);
[xopt,zmin,exitflag,output2,lambda] = linprog(C,A,B,Aeq,Beq,LB1,[],[],options);
If someone knows how to do it better, I will be happy to see a solution.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by