% You can do different types of manipulation!
y2 = flipud(y);
y3 = y .* linspace(1,0,M)'; % KEY: [*'] - transpose!

soundsc(y2, fs);

fprintf(1, 'Press any key...\n');
pause;

soundsc(y3, fs);

figure(2); clf;
subplot(311); plot(y); title('Fade-out');
subplot(312); plot(linspace(1,0,M));
subplot(313); plot(y3);
