how to define the below function ?

1 回表示 (過去 30 日間)
aditya sahu
aditya sahu 2017 年 5 月 8 日
コメント済み: Walter Roberson 2017 年 5 月 8 日
How to define the function f1= 2n<->2n+1 i.e it defines two transformations.
1. from value 2n to 2n+1.
2.from value 2n+1 to 2n.
Example. i.e let x= 30 (00011110). if we embed 0/1 then the result will be for 0= 30(00011110) i.e 2n for 1= 31(00011111) i.e 2n+1.
Thank you.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 5 月 8 日
@(v) v + 1 - 2*mod(v, 2)
  2 件のコメント
aditya sahu
aditya sahu 2017 年 5 月 8 日
Dear , Walter Roberson i could not understood your answer, Actually i need to write as function. would you please clarify more in detail about your answer . Thank you.
Walter Roberson
Walter Roberson 2017 年 5 月 8 日
function value = f1(x)
value = x + 1 - 2*mod(x, 2);

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by