# wavelength (m) of a 2000 Hz air-borne sound at 20°C
wasp(f=2000)$l
# [1] 0.1717
# sound speed in sea at 0 and -500 m for a respective temperature of 22°C and 11°C
wasp(f=1000,s=30,d=c(0,500),t=c(22,11),medium="sea")$c
# [1] 1521.246 1495.414
# wavelength (m) of a 1000 Hz sound in a medium unspecified where c = 1497 m/s
wasp(f=1000,c=1497)$l
# [1] 1.497
# variation of wavelength according to frequency and air temperature
op<-par(bg="lightgrey")
a<-seq(1000,20000,by=100) ; na<-length(a)
b<-seq(-20,40,by=10) ; nb<-length(b)
res<-matrix(numeric(na*nb),nrow=na)
for(i in 1:nb) res[,i]<-wasp(a,t=b[i])$l
matplot(x=a,y=res,type="l",lty=1,col= spectro.colors(nb),
xlab="Frequency (Hz)",ylab="Wavelength (m)")
title("Wavelength of air-borne sound at different temperatures")
legend(x=15000,y=0.3,c("-20°C","-10°C","0°C","10°C","20°C","30°C","40°C"),
lty=1,col= spectro.colors(nb),bg="grey")
par(op)
Run the code above in your browser using DataLab