how to implement these equations in Matlab?

I have the following equations
where and represent the first-order derivative of matrix I . I tried to implement these equations in matlab using the following lines:
fx = diff(I,1,2);
fx = padarray(fx, [0 1 0], 'post');
fy = diff(I,1,1);
fy = padarray(fy, [1 0 0], 'post');
Gx = -log10(fx);
Gy = -log10(fy);
however, the value of Gx and Gy are complex numbers which means that these equations don't implemented correctely. does anyone know how to implement these equations correctely in matlab? any help will be appreciated.

5 件のコメント

VBBV
VBBV 2020 年 10 月 2 日
編集済み: Walter Roberson 2020 年 10 月 2 日
fx = padarray(fx,[0 1],0,'post');
Similarly for fy. The second argument in pad array is size of matrix. Third arg is value
ghada sandoub
ghada sandoub 2020 年 10 月 2 日
thanks for your response. do you mean that the remaining lines of code are correct and this will calculate the logarithmic of derivative correctly?
VBBV
VBBV 2020 年 10 月 2 日
編集済み: Walter Roberson 2020 年 10 月 2 日
May be use natural log instead of decimal log
Gx = -log(fx);
John D'Errico
John D'Errico 2020 年 10 月 2 日
natural log vs log10 is irrelevant. If one gives complex, than so will the other.
The log of a negative number is complex. Taken to ANY base.
VBBV
VBBV 2020 年 10 月 2 日
編集済み: VBBV 2020 年 10 月 2 日
Check if fx and fy Is producing negative values. Also verify the initial conidtions for generating I matrix used as input to diff function

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

回答 (0 件)

カテゴリ

製品

質問済み:

2020 年 10 月 1 日

編集済み:

2020 年 10 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by