MATLAB: Generate sound with specific frequencies

sounds

I wanted to make test sound within range of frequencies each freq sound takes 3 seconds. The whole test sond shoud be 42 seconds but when i run it it just plays for 3 seconds. what's the problem with my code ?
amp = 0.5;
Fs = 50 + 100 + 200 + 400 + 1000 + 2000 + 4000 + 6000 + 8000 + 10000 + 12000 + 14000 + 16000 + 18000;
Ts = 1/Fs;
T = 0:Ts:3;
sound(x,Fs)
for freq = [50 100 200 400 1000 2000 4000 6000 8000 10000 12000 14000 16000 18000]
x = amp * sin(2*pi*freq*T);
sound(x,Fs)
end

Best Answer

Mayar - playback the audio data outside of the loop. Inside the loop, concatenate the samples for each frequency into an array.
amp = 0.5;
Fs = 50 + 100 + 200 + 400 + 1000 + 2000 + 4000 + 6000 + 8000 + 10000 + 12000 + 14000 + 16000 + 18000;
Ts = 1/Fs;
T = 0:Ts:3;
x = [];
for freq = [50 100 200 400 1000 2000 4000 6000 8000 10000 12000 14000 16000 18000]
x = [ x amp * sin(2*pi*freq*T)];
end
sound(x,Fs)
Also consider using the audioplayer instead of sound.