Doxygen Source Code Documentation
model_sinewave_ap.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_sinewave_ap.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 sine wave model -----*/
00050
00051 /*----- name of this model -----*/
00052 strcpy (mi->label, "SineWave_AP");
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 = 2;
00059
00060 /*----- parameter labels -----*/
00061 strcpy (mi->plabel[0], "amplitude");
00062 strcpy (mi->plabel[1], "phase");
00063
00064 /*----- minimum and maximum parameter constraints -----*/
00065 mi->min_constr[0] = -100.0; mi->max_constr[0] = 100.0;
00066 mi->min_constr[1] = -90.0; mi->max_constr[1] = 0.00;
00067
00068 /*----- function which implements the model -----*/
00069 mi->call_func = &signal_model;
00070
00071
00072 /*----- return pointer to the model interface -----*/
00073 return (mi);
00074 }
|
|
||||||||||||||||||||
|
Definition at line 90 of file model_sinewave_ap.c. Referenced by initialize_model().
00097 {
00098 const float FREQ = 0.125; /* frequency of the sine wave */
00099 int it; /* time index */
00100 float t; /* time */
00101 float fval; /* time series value at time t */
00102
00103
00104 /*----- calculate time series corresponding to the given parameters -----*/
00105 for (it = 0; it < ts_length; it++)
00106 {
00107 t = x_array[it][1];
00108 fval = gs[0] * sin( 2.0*PI*FREQ*t + (PI/180.0)*gs[1] );
00109 ts_array[it] = fval;
00110 }
00111
00112 }
|