Invalid use of operator...it is saying it has a problem with '&&' in line 52

3 ビュー (過去 30 日間)
Donny Flynn
Donny Flynn 2021 年 2 月 25 日
編集済み: Donny Flynn 2021 年 2 月 25 日
clc
%%====== Setup =========
S = [[3000 1000 2000];[1000 1000 4000];[2000 500 3000]];
sol = [];
c = S(:,4);
B = S; B(:,4) = [];
[sr sc] = size(B);
Axes = eye(sc);
%% ============ Find Interceptions ===============
A = [B(1,:);B(2,:)];
b = [c(1);c(2)];
sol = [sol linsolve(A,b)];
A = [B(1,:);B(3,:)];
b =[c(1);c(3)];
sol = [sol linsolve(A,b)];
A = [B(2,:);B(3,:)];
b = [c(2);c(3)];
sol = [sol linsolve(A,b)];
%% === Check for axes intersections ==
for i=1:sc
for j=1:sr
A = [Axes(i,:);B(j,:)];
b = [0;c(j)];
sol = [sol linsolve(A,b)];
end
end
%% === Find corner points of feasible
%% === region ======
[r c] = size(sol);
feasible = []; tolerance = 0;
for i=1:c
v = (sol(:,i));
x = v(1); y = v(2); z = v(3);
if (3000*x + 1000*y + 2000*z) <= 24000 + tolerance
&& (1000*x + 1000*y + 4000*z) <= 16000 + tolerance &&
(2000*x + 500*y + 3000*z) <= 48800 + tolerance
feasible = [feasible sol(:,i)];
end
end
disp(feasible)
%% ====== Find optimum =======
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 25 日
There are multiple issues, S has 3 columns data
> whos S
Name Size Bytes Class Attributes
S 3x3 72 double
But, you are trying to access 4th
c = S(:,4);
Donny Flynn
Donny Flynn 2021 年 2 月 25 日
編集済み: Donny Flynn 2021 年 2 月 25 日
Yes I noticed that, i changed it to 3. Thank you.
What were the other issus?

サインインしてコメントする。

採用された回答

David Hill
David Hill 2021 年 2 月 25 日
To continue the line of code you need three dots ...
if (3000*x + 1000*y + 2000*z) <= 24000 + tolerance ...
&& (1000*x + 1000*y + 4000*z) <= 16000 + tolerance &&...
(2000*x + 500*y + 3000*z) <= 48800 + tolerance
feasible = [feasible sol(:,i)];
end
  1 件のコメント
Donny Flynn
Donny Flynn 2021 年 2 月 25 日
Thank you I am not too familair with MATLAB...learning the syntax, I appreciate it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by