<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.

1 回表示 (過去 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 Center および File ExchangeSolver 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