# 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
{"ft_lang_label":"__label__en","ft_lang_prob":0.720421,"math_prob":0.8914813,"size":413,"snap":"2019-43-2019-47","text_gpt3_token_len":130,"char_repetition_ratio":0.07334963,"word_repetition_ratio":0.0,"special_character_ratio":0.30750605,"punctuation_ratio":0.15384616,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99241245,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-17T07:41:04Z\",\"WARC-Record-ID\":\"<urn:uuid:819b3137-5538-48e6-8b6f-b37eeb52bd60>\",\"Content-Length\":\"141932\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a83d0aad-f600-4bb3-8741-fa42baf05c22>\",\"WARC-Concurrent-To\":\"<urn:uuid:5ec0d4c8-b1fa-4fb9-bae2-7e9bf2932bcc>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://dsp.stackexchange.com/questions/24378/could-not-construct-original-matrix-using-svd\",\"WARC-Payload-Digest\":\"sha1:ZHIUR4EHPV6WSYUCK5A5F7BJ7GIAFNZT\",\"WARC-Block-Digest\":\"sha1:JSFMDNTYXQ255CIPHGWIO6ZJXPRCINUG\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668896.47_warc_CC-MAIN-20191117064703-20191117092703-00527.warc.gz\"}"}