[Scilab-users] Generation of linear frequency

Lester Anderson arctica1963 at gmail.com
Sun Mar 10 10:49:49 CET 2013


On 10 March 2013 09:02, TViT <tvitklg at rambler.ru> wrote:

> Hello!
>
> In Matlab there is a function chirp, and what is in Scilab?
>
> And why Scilab can not transform a simple example from Matlab of a file?
>
> //-----------------------------------------------------
> t = 0:0.001:2;            % 2 secs @ 1kHz sample rate
> y = chirp(t,0,1,150);     % Start @ DC,
>                           %   cross 150Hz at t=1 sec
> spectrogram(y,256,250,256,1E3,'yaxis')
> //-----------------------------------------------------
>
>  !--error 37
> at line     190 of function mfile2sci called by :
> at line     142 of function cb_m2sci_gui called by :
> cbo = getcallbackobject("-6ebf8d73:13d5388519a:-7f72");cb_m2sci_gui;if
> exists("%oldgcbo") then gcbo = %oldgcbo;
> while executing a callback
>
>
>
> --
> View this message in context:
> http://mailinglists.scilab.org/Generation-of-linear-frequency-tp4026202.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive
> at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>

Google the function as chirp.m and you will get the code:

function   x = chirp( T, W, p )
%CHIRP    generate a sampled chirp signal
%-----       exp(j(W/T)pi*t^2)   -T/2 <= t < +T/2
%
%   Usage:   X = chirp( T, W, <P> )
%
%      X :  N=pTW samples of a "chirp" signal
%      T :  time duration from -T/2 to +T/2
%      W :  swept bandwidth from -W/2 to +W/2
%
%   optional (default is P = 1)
%      P :  samples at P times the Nyquist rate (W)
%            i.e., sampling interval is 1/(PW)

%---------------------------------------------------------------
% copyright 1994, by C.S. Burrus, J.H. McClellan, A.V. Oppenheim,
% T.W. Parks, R.W. Schafer, & H.W. Schussler.  For use with the book
% "Computer-Based Exercises for Signal Processing Using MATLAB"
% (Prentice-Hall, 1994).
%---------------------------------------------------------------

if nargin < 3
   p = 1;   end
J = sqrt(-1);
%--------------
delta_t = 1/(p*W);
N = round( p*T*W );    %--- same as T/delta_t
nn = [0:N-1]';
x = exp( J*pi*W/T * (delta_t*nn - T/2).^2 );

 Just recode in Scilab and place in your main source code or set in a
functions libarry to be called.
May be different versions of this so best to check around
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130310/e71a79af/attachment.htm>


More information about the users mailing list