Problen with using varsize

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?

 采纳的回答

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 个)

类别

帮助中心File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by