Hi Claus, I am not aware of such function. However, you can find simple code here below for both phase modulation and demodulation, which is straightforward to translate in Scilab: https://www.gaussianwaves.com/2017/06/phase-demodulation-using-hilbert-transform-application-of-analytic-signal/
Note that the phase modulation is coded differently from you snippet below. Regards, Rafael From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Claus Futtrup Sent: Friday, May 25, 2018 7:17 PM To: International users mailing list for Scilab. <users@lists.scilab.org> Subject: [Scilab-users] Simulating phase modulation 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 samples y1 = 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-domain endplot = 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 points f=sample_rate*(0:(N/2))/N; //associated frequency vector n=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 users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users