Error in line for CVX

조회 수: 6 (최근 30일)
Aniz Mohamed Rafeeck
Aniz Mohamed Rafeeck 2021년 9월 26일
댓글: the cyclist 2021년 9월 27일
T = 3;
K = 3;
q = 1;
p = [10,1,8];
v = {};
v(1,:) = {[0.08 0.01 1.13;
0 0.02 1.1;
0 0 1.03]};
v(2,:) = {[0.06 0.03 1.07;
0 0.04 1.16;
0 0 1.04]};
v(3,:) = {[0.03 0.01 1.08;
0 0.08 1.01;
0 0.0 1.1]};
cvx_begin
v_max = [0.08 0.01 1.13;
0 0.04 1.16;
0 0 1.1];
variable m(3);
expression P(3);
for i = 1:T
P(i) = (1+1/100)^(m(i)-i)*(1+sum(v_max(m(i),:)));
end
minimize(sum(P))
subject to
for i = 1:T
m(i)<=T;
m(i)>=i;
end
cvx_end
I get an error as

답변 (2개)

the cyclist
the cyclist 2021년 9월 26일
I don't know CVX, but the error message seems straightforward. My best guess is that m is a variable of type cvx, and you are trying to use it as an index in this expression:
v_max(m(i),:)
It seems that this syntax is not allowed. Perhaps there is some kind of type conversion you can use.
  댓글 수: 2
Aniz Mohamed Rafeeck
Aniz Mohamed Rafeeck 2021년 9월 27일
How do you rectify it
the cyclist
the cyclist 2021년 9월 27일
I don't know. You are asking a CVX question, not a MATLAB question. Maybe you can find a forum for CVX.

댓글을 달려면 로그인하십시오.


Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 26일
Here is the corrected part of the code:
...
%cvx_begin % Invalid MATLAB command
v_max = [0.08 0.01 1.13;
0 0.04 1.16;
0 0 1.1];
% variable m(3); % Invalid MATLAB command
% expression P(3); % Invalid MATLAB command
m= [1, 2, 3];
for i = 1:T
P(i) = (1+1/100)^(m(i)-i)*(1+sum(v_max(m(i),:)));
end
min(sum(P))
for i = 1:T
m(i)<=T;
m(i)>=i;
end
% cvx_end % Invalid MATLAB command
  댓글 수: 1
the cyclist
the cyclist 2021년 9월 26일
Those commands are valid for the CVX toolbox.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by