<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 (최근 30일)
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

답변 (1개)

Vimal Rathod
Vimal Rathod 2020년 11월 24일
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

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by