フィルターのクリア

How to do symbolic mod operation

3 ビュー (過去 30 日間)
DmArcher
DmArcher 2017 年 4 月 24 日
編集済み: DmArcher 2017 年 4 月 24 日
I try to do mod function with symbolic variables. Is there a way to do something like mod(a+b,b)=a which means that the reminder of (a+b) divided by b is a. But MATLAB doesn't allow both the parameters of the mod function be symbolic. Could someone help me?

採用された回答

Steven Lord
Steven Lord 2017 年 4 月 24 日
When calling the mod function with symbolic inputs, the second input must be a matrix (which can be a vector or a scalar) of numbers or symbolic number.
"Divisor (denominator), specified as a number, symbolic number, or a vector or matrix of numbers or symbolic numbers."
The symbolic variable b isn't a number or symbolic number.
As for your statement that mod(a+b, b) is equal to a, that's not quite true.
a = 5;
b = 3;
equalsA = mod(a+b, b) == a % returns false
equivalentA = mod(a+b, b) == mod(a, b) % returns true
If you want to use symbolic numbers, you will need to wrap the commands that define equalsA and equivalentA in isAlways calls to convert them into true or false.
a = sym(5);
b = sym(3);
equalsA = isAlways(mod(a+b, b) == a) % returns false
equivalentA = isAlways(mod(a+b, b) == mod(a, b)) % returns true
  1 件のコメント
DmArcher
DmArcher 2017 年 4 月 24 日
編集済み: DmArcher 2017 年 4 月 24 日
Is there a way to compute in MATLAB about (2*a+b) to count that it contains two a and one b? So that I can use subtraction to get the reminder.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by