Filter löschen
Filter löschen

Problen with using varsize

2 Ansichten (letzte 30 Tage)
Grek Vardugin
Grek Vardugin am 4 Nov. 2018
Beantwortet: Grek Vardugin am 12 Nov. 2018
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?

Akzeptierte Antwort

Grek Vardugin
Grek Vardugin am 12 Nov. 2018
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.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by