I’m trying to export the data that is shown in plot(yi) using wavwrite. When I do an interpolation the (yi) signal doesn’t start at zero how can I get (yi) the interpolated signal to start at zero? Please note that I can’t just do a plot(xxorig, yi) due to the fact that wavwrite doesn’t work this way. Does anyone know a work around?
I’m using octave 3.2.4/matlab
clear all, clf
xxorig=[0, 0.418879, 0.837758, 1.25664, 1.67552, 2.0944, 2.51327, 2.93215, 3.35103, 3.76991, 4.18879, 4.60767, 5.02655, 5.44543, 5.86431, 6.28319];
xx=[0, 0.296192, 0.592384, 0.888577, 1.18477, 1.48096, 1.77715, 2.07335, 2.36954, 2.66573, 2.96192, 3.25811, 3.55431, 3.8505, 4.14669, 4.44288];
yy=[0, 0.406737, 0.743145, 0.951057, 0.994522, 0.866025, 0.587785, 0.207912, -0.207912, -0.587785, -0.866025, -0.994522, -0.951057, -0.743145, -0.406737, -2.44929e-16];
yi=interp1(xx,yy,xxorig);
subplot(4,1,1),plot(xxorig,yy),title("plot(xxorig,yy)")
subplot(4,1,2),plot(xx,yy),title("plot(xx,yy)")
subplot(4,1,3),plot(yy),title("plot(yy)")
subplot(4,1,4),plot(yi),title("plot(yi)")
wavwrite([yy'] ,16,32,'/tmp/test.wav')

It’s unclear what are you trying to export – plot or sound wav file of the signal?
You use WAVWRITE to save the sound in WAVE format. In this case you pass signal intensity
yiand optionally a sample rate (the default rate is 8000 Hz). You souldn’t care that your signal does not start at 0.I believe you can calculate your sample rate for
yiasIf you want to PLOT the signal you specify the time on X axis. If you don’t pass x to the
plotfunction it uses just order numbers starting from 1. This is why yourplot(yi)orplot(yy)curve does not start at 0.