Doxygen Source Code Documentation
model_trnglwave_apf.c File Reference
#include <math.h>#include "NLfit_model.h"Go to the source code of this file.
| Functions | |
| void | signal_model (float *gs, int ts_length, float **x_array, float *ts_array) | 
| DEFINE_MODEL_PROTOTYPE MODEL_interface * | initialize_model () | 
Function Documentation
| 
 | 
| 
 Definition at line 40 of file model_trnglwave_apf.c. References MODEL_interface::call_func, MODEL_interface::label, MODEL_interface::max_constr, MODEL_interface::min_constr, MODEL_SIGNAL_TYPE, MODEL_interface::model_type, MODEL_interface::params, MODEL_interface::plabel, signal_model(), and XtMalloc. 
 00041 {
00042   MODEL_interface * mi = NULL;
00043 
00044 
00045   /*----- allocate memory space for model interface -----*/
00046   mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface));
00047 
00048 
00049   /*----- define interface for the triangular wave model -----*/   
00050 
00051   /*----- name of this model -----*/
00052   strcpy (mi->label, "TrnglrWave_APF");
00053 
00054   /*----- this is a signal model -----*/
00055   mi->model_type = MODEL_SIGNAL_TYPE;
00056 
00057   /*----- number of parameters in the model -----*/
00058   mi->params = 3;
00059 
00060   /*----- parameter labels -----*/
00061   strcpy (mi->plabel[0], "amplitude");
00062   strcpy (mi->plabel[1], "phase");
00063   strcpy (mi->plabel[2], "frequency");
00064 
00065   /*----- minimum and maximum parameter constraints -----*/
00066   mi->min_constr[0] =   -100.0;    mi->max_constr[0] =   100.0;
00067   mi->min_constr[1] =    -90.0;    mi->max_constr[1] =     0.00;
00068   mi->min_constr[2] =      0.1;    mi->max_constr[2] =     0.15;
00069   
00070   /*----- function which implements the model -----*/
00071   mi->call_func = &signal_model;
00072 
00073 
00074   /*----- return pointer to the model interface -----*/
00075   return (mi);
00076 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 93 of file model_trnglwave_apf.c. Referenced by initialize_model(). 
 00100 {
00101   int it;                           /* time index */     
00102   float t;                          /* time */
00103   float fval;                       /* time series value at time t */  
00104   float cycles;                     /* number of cycles since initial time */
00105 
00106 
00107   /*----- calculate time series corresponding to the given parameters -----*/
00108   for (it = 0;  it < ts_length;  it++)
00109     {
00110       t = x_array[it][1];
00111       cycles = gs[2]*t + gs[1]/360.0;
00112       cycles = cycles - (int)cycles;
00113       if (cycles <= 0.25)
00114         fval = gs[0] * (cycles/0.25);
00115       else
00116         if ((cycles > 0.25) && (cycles <= 0.75))
00117           fval = gs[0] * (2.0 - (cycles/0.25));
00118         else
00119           fval = gs[0] * ((cycles/0.25) - 4.0);
00120       ts_array[it] = fval;      
00121     }
00122 }
 | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  