Hi there In a loudspeaker the driver can move several millimeter in an attempt to reproduce a low-frequency note. If the speaker also at the same time produce a higher tone, this second tone is phase modulated by the first one. This is a distortion of the original signal which I'd like to simulate / illustrate with some simple Scilab code, if possible.
In Matlab this can be simulated with pmmod. https://matlabandsimulink.wordpress.com/2013/03/12/phase-modulation/ Is there a similar function in Scilab? (name - please ?) Here's the code I have written so far - this is the part that shows the input signal (the un-distorted signal): sample_rate=20000;t = 0:1/sample_rate:0.6;N=size(t,'*'); //number of samplesy1 = sin(2*%pi*50*t);y2 = 0.5*sin(2*%pi*500*t);// y2 = 0.5*sin(2*%pi*500*t+%pi/4);s=y1+y2+grand(1,N,'nor',0,1); // Plot time-domainendplot = round(N/15);twoplots = scf(); // Set Current Figure (Graphics Window)subplot(211);plot(t(1:endplot),y1(1:endplot),t(1:endplot),y2(1:endplot));subplot(212);plot(t(1:endplot),y1(1:endplot)+y2(1:endplot)); y=fft(s);ymax = max(abs(y));y = y ./ ymax; // Normalize // s is real so the fft response is conjugate symmetric// and we retain only the first N/2 pointsf=sample_rate*(0:(N/2))/N; //associated frequency vectorn=size(f,'*');fftplots = scf();plot(f(2:$),abs(y(2:n))); // drop first datapoint, f = 0 (it prevents log-plot)a = gca();a.log_flags = "lnn"; Best regards, Claus
_______________________________________________ users mailing list [email protected] http://lists.scilab.org/mailman/listinfo/users
