<stopping criteria details> Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-69.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have to solve this problem.
min x*sigma*x
with
h=linspace(h_min,h_max,50)
D is a matrix 69x69
number variables 69
%constraints ceq and c
% for each h I have a vector of x, haven't it?
function[c,ceq]= nlcon (x)
load workspace17Rao.mat
n=length(D);
x=zeros(1,n);
h=linspace(h_min,h_max,50);
for i=1:length(h)
c(i)=h(i)-(x*D*x')
ceq=[];
end
end
%fmincon
close all; clear all; clc;
load workspace17Rao.mat
x=zeros(length(h),n);
h_min=0.639064969481681;
h_max=0.968289685083315;
h=linspace(h_min,h_max,50);
for i=1:length(h)
x=zeros(length(h),n)
fun=@(x) x*sigma*x';
x0_rao=zeros(i,n);
A_rao=[];
b_rao=[];
Aeq_rao=ones(i,n);
beq_rao=1;
risk_rao = zeros(i,n);
risk_rao(1) = var_min;
constr=@nlcon;
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[x(i,n), risk_rao(i)]=fmincon(fun,x0_rao,A_rao,b_rao,Aeq_rao,beq_rao,[],[],constr,options);
end
0 commentaires
Réponses (1)
Vimal Rathod
le 24 Nov 2020
Hi,
It is not clear in which line the error occurs, It seems like the left and right values don't have matching dimensions so if you could debug that by checking the value at that line.
Refer to the following link to know more about how to debug using breakpoints in MATLAB
0 commentaires
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!