In the last post, we saw how easiy we could accomplish complicated operations using DIECAL. Further to that, we are going develop a sine wave generator using a few lines of code. I know that you don't have a sine wave generator even in your wildest DIESEL dreams. But it is a really simple task using DIECAL. Once again, I am going to use points in order to make it simple. For generating sine wave, use the following macro.
*^C^C_setvar;userr1;$M=$(+,$(getvar,userr1),$(getvar,userr2))$(if,$(>=,$(*,$(+,$(getvar,userr1),$(getvar,userr2)),10),$(*,$(getvar,userr3),360)),^C)_Point;'CAL;[$(getvar,userr4)+$(+,$(getvar,userr1),$(getvar,userr2))/18,sin(10*$(+,$(getvar,userr1),$(getvar,userr2)))];
The above macro makes use of USERR1 to USERR4 system variables. The USERR1 and USERR2 values are automatically set by the set/reset macro (given below). USERR3 holds the value for number of cycles created and USERR4 is for X axis lag value (See the sample image). Use the following macro to set/reset initial values. When you run this macro, just follow the status bar messages.
^C^C_setvar;userr1;-1;;userr2;1;userr3;1;_modemacro;Enter number of cycles:;userr3;\userr4;0;_modemacro;Enter lag value for X axis:;setvar;userr4;\_modemacro;.;
The following image illustrates three sine waves gererated with a cycle value of 3 and X axis lag value 0 (Red) .22 (Green) and .44(Yellow).
Wednesday, November 19, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
hey - check this: www.lonelyengineer.com
Post a Comment