How do I invert nested functions in MATLAB?

If I have a variable (let's call it a) and then I apply the following multiple functions to transform it into a second variable, (b), how would I reverse it?
b = fftshift(fftn(fftshift(a)));
I tried doing the following:
c = ifftshift(ifftn(ifftshift(b)));
If this had worked, c would have been equal to a (the initial, non-transformed data set). Why doesn't it? Is there a better, more universal way of reversing the function initially applied to A? I tried finverse, but it didn't work in the way I used it because fftshift works on doubles, and I was using a sym-type variable when I tried getting the inverse.
Any help is appreciated

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 14 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 14 日

0 投票

"If I have a variable (let's call it a) and then I apply the following multiple functions to transform it into a second variable, (b), how would I reverse it?"
a=magic(3)
b = fftshift(fftn(fftshift(a)));
c = ifftshift(ifftn(ifftshift(b)))
Result:
a =
8 1 6
3 5 7
4 9 2
c =
8.0000 1.0000 6.0000
3.0000 5.0000 7.0000
4.0000 9.0000 2.0000

3 件のコメント

Ak K
Ak K 2019 年 8 月 14 日
Now that I take a closer look at the data (its hard to analyze since my data set is 88x88x88), it does appear that way; why does "isequal(a,c)" still return 0?
Walter Roberson
Walter Roberson 2019 年 8 月 14 日
編集済み: Walter Roberson 2019 年 8 月 15 日
Floating point roundoff. I suggest that you subtract the two versions and look at the difference.
fft involves the use of transcendental trig functions, so in order for the inverse to be always bit for bit exact, you would need to use indefinite precision.
You can use counting arguments to prove that if you use finite floating point that asin(sin(x)) cannot always exactly equal x even within the primary period.
Ak K
Ak K 2019 年 8 月 15 日
Got it, thanks; I tried that, and the difference was indeed extremely small.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolynomials についてさらに検索

製品

リリース

R2018a

質問済み:

2019 年 8 月 14 日

編集済み:

2019 年 8 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by