Matlab multiplication of two matrices in max-plus algebra?

조회 수: 4 (최근 30일)
Ammy
Ammy 2018년 2월 3일
댓글: Steven Lord 2018년 2월 3일
In max-plus algebra
x+y=max(x,y)
x*y=x+y
where x , y denote the entries.
How two multiply two matrices in MATLAB such that addition implies maximum value and multiplication imply sum .
Thanks

답변 (1개)

John D'Errico
John D'Errico 2018년 2월 3일
You will need to write the code, overloading + and * (thus the functions plus and mtimes) for inputs of class double. Then you need to learn how to overload operators in MATLAB.
This is a VERY bad idea, because that will completely disable addition or multiplication of matrices when next you use MATLAB for some other project. Worse, other functions in MATLAB will now fail, if they use addition or multiplication. Even scalar multiplies or adds will now fail to work properly.
As I said, that is just an insanely bad idea.
Instead, just write two functions myplus and mytimes (call them what you want, as long as they are not plus and times) that operate exactly as you wish. Then use them to compute the desired results, wherever you want those operations.
  댓글 수: 5
John D'Errico
John D'Errico 2018년 2월 3일
That will indeed work as long as you have created the matrices A and B as members of the maxplus class. But it will not apply to any general double precision matrices.
Steven Lord
Steven Lord 2018년 2월 3일
Write myplus:
function result = myplus(input1, input2)
% You need to fill in the body of the function
% so it does what you want
Now you would need to call this function on your arrays.
% Define A and B then call the function
C = myplus(A, B)

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by