sfstoolbox / sfs-matlab

SFS Toolbox for Matlab/Octave
https://sfs-matlab.readthedocs.io
MIT License
96 stars 39 forks source link

Extend spectrum_from_signal and signal_from_spectrum to multichannel signals #182

Closed fietew closed 6 years ago

fietew commented 6 years ago

Try:

SFS_start;
conf = SFS_config;
conf.plot.useplot = true;
SOFAstart;

irs = get_ir(dummy_irs(1024,conf),[0,0,0],0,[1 0 0], 'cartesian',conf);
[b1,a1] = butter(5,0.1);
[b2,a2] = butter(10,0.2);

sig1 = filter(b1,a1,irs(:,1));
sig2 = filter(b2,a2,irs(:,1));
sig = [irs(:,1), sig1, sig2];

[amp, phase, f] = spectrum_from_signal(sig,1,conf);
sig_inv = signal_from_spectrum(amp, phase, f, 1,conf);
figure, 
plot(sig,'k');
hold on
plot(sig_inv, '--');
hold off;

[amp, phase, f] = spectrum_from_signal(sig,conf);
sig_inv = signal_from_spectrum(amp, phase, f, conf);
figure, 
plot(sig,'k');
hold on
plot(sig_inv, '--');
hold off;

[amp, phase, f] = spectrum_from_signal(sig.',2,conf);
sig_inv = signal_from_spectrum(amp, phase,f,2,conf);
figure, 
plot(sig,'k');
hold on
plot(sig_inv.', '--');
hold off;
chris-hld commented 6 years ago

Looks good! Should we adjust the test script?

hagenw commented 6 years ago

Should be fine without adjusting the test script, I will merge this now.