How can I code these 2 equations?

Hello
Is it possible to write these as 1-1 assignment? given.
A is , b is and is . u and l are matrices
lambda.GIF
The problematic part is the sum and the or condition. How should I modify this?
lambda_2k1 = max((b-sum(A*x_c))/A(:,k)) + (u(k) - l(k))/2;

5 件のコメント

David K.
David K. 2019 年 9 月 17 日
Maybe this? I am assuming that the prelim val is a vector the same size as A(:,k)
prelimVal = (b-sum(A*x_c))/A(:,k);
val1 = prelimVal(A(:,k)<0);
val2 = prelimVal(A(:,k)>0);
lambda_2k1 = max(val1) + (u(k) - l(k))/2;
lambda_2k = min(val2) - (u(k) - l(k))/2;
Richárd Tóth
Richárd Tóth 2019 年 9 月 17 日
thanks, I think it should work
Richárd Tóth
Richárd Tóth 2019 年 9 月 17 日
We should use ./ instead of / in the first line since we need division by element, not matrix division right?
David K.
David K. 2019 年 9 月 17 日
Yes you do. Also, I think you may want to make sure the sum is summing the elements in the dimension you need them to be. If they are not, use sum( . . . , 2).
Richárd Tóth
Richárd Tóth 2019 年 9 月 17 日
Yes, summing on each row is needed and omitting the 2 gives different(incorrect) result

回答 (0 件)

この質問は閉じられています。

タグ

質問済み:

2019 年 9 月 17 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by