# Could not construct original matrix using SVD

I need to

• read a .wav file
• make a 2D matrix from it using the STFT
• generate its singular value decomposition
• do some watermarking

but I can't build the original matrix again via matrix multiplication:

 x = audioread('0.wav');
stft = spectrogram(x);
[U,S,V] = svd(stft);
stftb=U*S*V.';


The problem is that STFT and STFTb are not the same.

• What do you get when you type max(max(abs(stftb-stft)))? – Matt L. Jun 26 '15 at 9:59
• @MattL.ans = 76.2564 – Narges Jun 26 '15 at 14:23
• OK, since your matrices are complex-valued schvaba986's answer is the solution. – Matt L. Jun 26 '15 at 15:54

Don't have enough reputation to comment but you need to use the conjugate transpose in your formula for the result to be correct. So try stftb=U*S*V'; in the last line of code. Note that I removed the . which makes a difference since the matrices you are working with are complex.
• Why are they complex? stft is real-valued, isn't it? – Matt L. Jun 26 '15 at 10:03
• I think that MATLAB divides the signal in 8 segments and returns a complex value when you call the spectrogram function like that. – schvaba986 Jun 26 '15 at 10:20
• I guess you're right, spectrogram actually computes the short-time Fourier transform, not the spectrogram (which would be real-valued because it's a squared magnitude). – Matt L. Jun 26 '15 at 10:31