File: Datalogger4ChConverter_ErrInsensitiveSound.c

    1   /*
    2    * Datalogger4ChConverter_ErrInsensitiveSound.c
    3    *
    4    * Code generation for function 'Datalogger4ChConverter_ErrInsensitiveSound'
    5    *
    6    */
    7   
    8   /* Include files */
    9   #include "rt_nonfinite.h"
   10   #include "Datalogger4ChConverter_ErrInsensitiveSound.h"
   11   #include "Datalogger4ChConverter_ErrInsensitiveSound_emxutil.h"
   12   #include "error.h"
   13   #include "eml_int_forloop_overflow_check.h"
   14   #include "scalexpAlloc.h"
   15   #include "nullAssignment.h"
   16   #include "sum.h"
   17   #include "fclose.h"
   18   #include "fread.h"
   19   #include "fopen.h"
   20   #include "Datalogger4ChConverter_ErrInsensitiveSound_data.h"
   21   #include <stdio.h>
   22   
   23   /* Variable Definitions */
   24   static emlrtRSInfo emlrtRSI = { 4, "Datalogger4ChConverter_ErrInsensitiveSound",
   25     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   26   };
   27   
   28   static emlrtRSInfo b_emlrtRSI = { 5,
   29     "Datalogger4ChConverter_ErrInsensitiveSound",
   30     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   31   };
   32   
   33   static emlrtRSInfo c_emlrtRSI = { 6,
   34     "Datalogger4ChConverter_ErrInsensitiveSound",
   35     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   36   };
   37   
   38   static emlrtRSInfo d_emlrtRSI = { 35,
   39     "Datalogger4ChConverter_ErrInsensitiveSound",
   40     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   41   };
   42   
   43   static emlrtRSInfo e_emlrtRSI = { 38,
   44     "Datalogger4ChConverter_ErrInsensitiveSound",
   45     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   46   };
   47   
   48   static emlrtRSInfo f_emlrtRSI = { 42,
   49     "Datalogger4ChConverter_ErrInsensitiveSound",
   50     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   51   };
   52   
   53   static emlrtRSInfo g_emlrtRSI = { 49,
   54     "Datalogger4ChConverter_ErrInsensitiveSound",
   55     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   56   };
   57   
   58   static emlrtRSInfo h_emlrtRSI = { 51,
   59     "Datalogger4ChConverter_ErrInsensitiveSound",
   60     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   61   };
   62   
   63   static emlrtRSInfo i_emlrtRSI = { 53,
   64     "Datalogger4ChConverter_ErrInsensitiveSound",
   65     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   66   };
   67   
   68   static emlrtRSInfo j_emlrtRSI = { 54,
   69     "Datalogger4ChConverter_ErrInsensitiveSound",
   70     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   71   };
   72   
   73   static emlrtRSInfo k_emlrtRSI = { 55,
   74     "Datalogger4ChConverter_ErrInsensitiveSound",
   75     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   76   };
   77   
   78   static emlrtRSInfo l_emlrtRSI = { 56,
   79     "Datalogger4ChConverter_ErrInsensitiveSound",
   80     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   81   };
   82   
   83   static emlrtRSInfo m_emlrtRSI = { 57,
   84     "Datalogger4ChConverter_ErrInsensitiveSound",
   85     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
   86   };
   87   
   88   static emlrtRSInfo fb_emlrtRSI = { 21, "colon",
   89     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
   90   
   91   static emlrtRSInfo gb_emlrtRSI = { 79, "colon",
   92     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
   93   
   94   static emlrtRSInfo hb_emlrtRSI = { 283, "colon",
   95     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
   96   
   97   static emlrtRSInfo ib_emlrtRSI = { 291, "colon",
   98     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
   99   
  100   static emlrtRSInfo jb_emlrtRSI = { 39, "reshape",
  101     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elmat\\reshape.m"
  102   };
  103   
  104   static emlrtRSInfo kb_emlrtRSI = { 61, "reshape",
  105     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elmat\\reshape.m"
  106   };
  107   
  108   static emlrtRSInfo lb_emlrtRSI = { 108, "reshape",
  109     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elmat\\reshape.m"
  110   };
  111   
  112   static emlrtRSInfo mb_emlrtRSI = { 131, "reshape",
  113     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elmat\\reshape.m"
  114   };
  115   
  116   static emlrtRSInfo nb_emlrtRSI = { 34, "bitshift",
  117     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\bitshift.m"
  118   };
  119   
  120   static emlrtRTEInfo emlrtRTEI = { 1, 30,
  121     "Datalogger4ChConverter_ErrInsensitiveSound",
  122     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  123   };
  124   
  125   static emlrtRTEInfo b_emlrtRTEI = { 16, 9, "scalexpAlloc",
  126     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\scalexpAlloc.m"
  127   };
  128   
  129   static emlrtRTEInfo c_emlrtRTEI = { 5, 1,
  130     "Datalogger4ChConverter_ErrInsensitiveSound",
  131     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  132   };
  133   
  134   static emlrtRTEInfo d_emlrtRTEI = { 8, 1,
  135     "Datalogger4ChConverter_ErrInsensitiveSound",
  136     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  137   };
  138   
  139   static emlrtRTEInfo e_emlrtRTEI = { 37, 1,
  140     "Datalogger4ChConverter_ErrInsensitiveSound",
  141     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  142   };
  143   
  144   static emlrtRTEInfo f_emlrtRTEI = { 39, 1,
  145     "Datalogger4ChConverter_ErrInsensitiveSound",
  146     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  147   };
  148   
  149   static emlrtRTEInfo m_emlrtRTEI = { 404, 15, "colon",
  150     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
  151   
  152   static emlrtRTEInfo n_emlrtRTEI = { 17, 19, "scalexpAlloc",
  153     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\scalexpAlloc.m"
  154   };
  155   
  156   static emlrtRTEInfo o_emlrtRTEI = { 53, 23, "assertValidSizeArg",
  157     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\assertValidSizeArg.m"
  158   };
  159   
  160   static emlrtRTEInfo p_emlrtRTEI = { 71, 15, "reshape",
  161     "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elmat\\reshape.m"
  162   };
  163   
  164   static emlrtECInfo emlrtECI = { -1, 56, 1,
  165     "Datalogger4ChConverter_ErrInsensitiveSound",
  166     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  167   };
  168   
  169   static emlrtECInfo b_emlrtECI = { -1, 55, 1,
  170     "Datalogger4ChConverter_ErrInsensitiveSound",
  171     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  172   };
  173   
  174   static emlrtECInfo c_emlrtECI = { -1, 54, 1,
  175     "Datalogger4ChConverter_ErrInsensitiveSound",
  176     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  177   };
  178   
  179   static emlrtECInfo d_emlrtECI = { -1, 53, 1,
  180     "Datalogger4ChConverter_ErrInsensitiveSound",
  181     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  182   };
  183   
  184   static emlrtECInfo e_emlrtECI = { -1, 56, 10,
  185     "Datalogger4ChConverter_ErrInsensitiveSound",
  186     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  187   };
  188   
  189   static emlrtECInfo f_emlrtECI = { -1, 55, 10,
  190     "Datalogger4ChConverter_ErrInsensitiveSound",
  191     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  192   };
  193   
  194   static emlrtECInfo g_emlrtECI = { -1, 54, 10,
  195     "Datalogger4ChConverter_ErrInsensitiveSound",
  196     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  197   };
  198   
  199   static emlrtECInfo h_emlrtECI = { -1, 53, 10,
  200     "Datalogger4ChConverter_ErrInsensitiveSound",
  201     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  202   };
  203   
  204   static emlrtECInfo i_emlrtECI = { -1, 42, 3,
  205     "Datalogger4ChConverter_ErrInsensitiveSound",
  206     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  207   };
  208   
  209   static emlrtBCInfo emlrtBCI = { -1, -1, 42, 17, "L",
  210     "Datalogger4ChConverter_ErrInsensitiveSound",
  211     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  212     0 };
  213   
  214   static emlrtBCInfo b_emlrtBCI = { -1, -1, 42, 28, "A",
  215     "Datalogger4ChConverter_ErrInsensitiveSound",
  216     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  217     0 };
  218   
  219   static emlrtDCInfo emlrtDCI = { 42, 28,
  220     "Datalogger4ChConverter_ErrInsensitiveSound",
  221     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  222     1 };
  223   
  224   static emlrtBCInfo c_emlrtBCI = { -1, -1, 42, 41, "V",
  225     "Datalogger4ChConverter_ErrInsensitiveSound",
  226     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  227     0 };
  228   
  229   static emlrtBCInfo d_emlrtBCI = { -1, -1, 42, 32, "V",
  230     "Datalogger4ChConverter_ErrInsensitiveSound",
  231     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  232     0 };
  233   
  234   static emlrtECInfo j_emlrtECI = { -1, 37, 5,
  235     "Datalogger4ChConverter_ErrInsensitiveSound",
  236     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m"
  237   };
  238   
  239   static emlrtBCInfo e_emlrtBCI = { -1, -1, 33, 5, "V",
  240     "Datalogger4ChConverter_ErrInsensitiveSound",
  241     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  242     0 };
  243   
  244   static emlrtBCInfo f_emlrtBCI = { -1, -1, 25, 10, "V",
  245     "Datalogger4ChConverter_ErrInsensitiveSound",
  246     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  247     0 };
  248   
  249   static emlrtBCInfo g_emlrtBCI = { -1, -1, 15, 17, "A",
  250     "Datalogger4ChConverter_ErrInsensitiveSound",
  251     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  252     0 };
  253   
  254   static emlrtBCInfo h_emlrtBCI = { -1, -1, 14, 17, "A",
  255     "Datalogger4ChConverter_ErrInsensitiveSound",
  256     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  257     0 };
  258   
  259   static emlrtDCInfo b_emlrtDCI = { 39, 12,
  260     "Datalogger4ChConverter_ErrInsensitiveSound",
  261     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  262     1 };
  263   
  264   static emlrtDCInfo c_emlrtDCI = { 39, 12,
  265     "Datalogger4ChConverter_ErrInsensitiveSound",
  266     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  267     4 };
  268   
  269   static emlrtDCInfo d_emlrtDCI = { 42, 3,
  270     "Datalogger4ChConverter_ErrInsensitiveSound",
  271     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  272     1 };
  273   
  274   static emlrtBCInfo i_emlrtBCI = { -1, -1, 42, 3, "Af",
  275     "Datalogger4ChConverter_ErrInsensitiveSound",
  276     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  277     0 };
  278   
  279   static emlrtBCInfo j_emlrtBCI = { -1, -1, 43, 21, "L",
  280     "Datalogger4ChConverter_ErrInsensitiveSound",
  281     "D:\\CodeToNatureMethods27102017\\Datalogger4ChConverter_ErrInsensitiveSound.m",
  282     0 };
  283   
  284   /* Function Definitions */
  285   void Datalogger4ChConverter_ErrInsensitiveSound(const emlrtStack *sp, const
  286     emxArray_char_T *Name_tmp, emxArray_real32_T *B, emxArray_uint8_T *Sync,
  287     real_T *Vcount)
  288   {
  289     emxArray_uint8_T *A;
  290     emxArray_real_T *V;
  291     real_T fid;
  292     int32_T maxdimlen;
  293     int32_T i0;
  294     boolean_T Error;
  295     uint32_T StartPos;
  296     uint32_T CurrentPos;
  297     emxArray_int32_T *r0;
  298     int32_T i1;
  299     real_T anew;
  300     emxArray_real_T *L;
  301     emxArray_uint8_T *Af;
  302     real_T Af_length;
  303     real_T Counter;
  304     int32_T I_t;
  305     emxArray_real_T *y;
  306     int32_T i2;
  307     emxArray_int32_T *b_Af;
  308     int32_T nm1d2;
  309     int32_T n;
  310     real_T apnd;
  311     real_T ndbl;
  312     boolean_T overflow;
  313     real_T cdiff;
  314     real_T absb;
  315     emxArray_uint8_T *b_y;
  316     emxArray_uint8_T *b_A;
  317     emxArray_uint16_T *a;
  318     emxArray_uint16_T *r1;
  319     emxArray_int32_T *r2;
  320     emxArray_real32_T *r3;
  321     int32_T iv0[1];
  322     int32_T iv1[1];
  323     int32_T iv2[1];
  324     int32_T iv3[1];
  325     emlrtStack st;
  326     emlrtStack b_st;
  327     emlrtStack c_st;
  328     emlrtStack d_st;
  329     st.prev = sp;
  330     st.tls = sp->tls;
  331     b_st.prev = &st;
  332     b_st.tls = st.tls;
  333     c_st.prev = &b_st;
  334     c_st.tls = b_st.tls;
  335     d_st.prev = &c_st;
  336     d_st.tls = c_st.tls;
  337     emlrtHeapReferenceStackEnterFcnR2012b(sp);
  338     emxInit_uint8_T(sp, &A, 1, &c_emlrtRTEI, true);
  339     emxInit_real_T(sp, &V, 2, &d_emlrtRTEI, true);
  340     covrtLogFcn(&emlrtCoverageInstance, 0U, 0);
  341     covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 0);
  342   
  343     /* Ku = [101 11 101 11];    %for sound recorder */
  344     /* Coef = single(2000./Ku/2048);  %in mV */
  345     st.site = &emlrtRSI;
  346     fid = b_fopen(&st, Name_tmp);
  347     st.site = &b_emlrtRSI;
  348     b_fread(&st, fid, A);
  349     st.site = &c_emlrtRSI;
  350     b_fclose(&st, fid);
  351     maxdimlen = (int32_T)muDoubleScalarCeil((real_T)A->size[0] / 6.0);
  352     i0 = V->size[0] * V->size[1];
  353     V->size[0] = maxdimlen;
  354     V->size[1] = 2;
  355     emxEnsureCapacity(sp, (emxArray__common *)V, i0, (int32_T)sizeof(real_T),
  356                       &emlrtRTEI);
  357     maxdimlen <<= 1;
  358     for (i0 = 0; i0 < maxdimlen; i0++) {
  359       V->data[i0] = rtNaN;
  360     }
  361   
  362     *Vcount = 0.0;
  363   
  364     /* Af = []; V = []; */
  365     Error = false;
  366     StartPos = 1U;
  367     CurrentPos = 2U;
  368     while (covrtLogWhile(&emlrtCoverageInstance, 0U, 0U, 0, CurrentPos < (real_T)
  369                          A->size[0] - 3.0)) {
  370       covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 1);
  371   
  372       /* FSize-4 -> FSize-3 */
  373       i0 = A->size[0];
  374       i1 = (int32_T)CurrentPos;
  375       if (!(i1 <= i0)) {
  376         emlrtDynamicBoundsCheckR2012b(i1, 1, i0, &h_emlrtBCI, sp);
  377       }
  378   
  379       /* with synchronization! rem +1 ->  1.4391s */
  380       i0 = A->size[0];
  381       i1 = (int32_T)CurrentPos + 3;
  382       if (!(i1 <= i0)) {
  383         emlrtDynamicBoundsCheckR2012b(i1, 1, i0, &g_emlrtBCI, sp);
  384       }
  385   
  386       if (covrtLogCond(&emlrtCoverageInstance, 0U, 0U, 0, (A->data[(int32_T)
  387             CurrentPos - 1] & 128) != 0) && covrtLogCond(&emlrtCoverageInstance,
  388            0U, 0U, 1, (A->data[(int32_T)CurrentPos + 2] & 136) == 0)) {
  389         covrtLogMcdc(&emlrtCoverageInstance, 0U, 0U, 0, true);
  390         covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 0, true);
  391         covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 2);
  392   
  393         /* 1.5198s; (b12==0) && (b34==0):1.7629s/1e7iter; (b12|b34)==0:1.7461s %no error   */
  394         CurrentPos += 6U;
  395         if (covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 1, Error)) {
  396           covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 3);
  397           StartPos = CurrentPos - 1U;
  398         }
  399   
  400         covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 4);
  401         Error = false;
  402       } else {
  403         covrtLogMcdc(&emlrtCoverageInstance, 0U, 0U, 0, false);
  404         covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 0, false);
  405   
  406         /* error */
  407         if (covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 2, covrtLogMcdc
  408                        (&emlrtCoverageInstance, 0U, 0U, 1, !covrtLogCond
  409                         (&emlrtCoverageInstance, 0U, 0U, 2, Error)))) {
  410           covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 5);
  411           (*Vcount)++;
  412           maxdimlen = V->size[0];
  413           i0 = (int32_T)*Vcount;
  414           if (!((i0 >= 1) && (i0 <= maxdimlen))) {
  415             emlrtDynamicBoundsCheckR2012b(i0, 1, maxdimlen, &f_emlrtBCI, sp);
  416           }
  417   
  418           maxdimlen = i0 - 1;
  419           V->data[maxdimlen] = StartPos;
  420           V->data[maxdimlen + V->size[0]] = (real_T)CurrentPos - 2.0;
  421           Error = true;
  422         }
  423   
  424         covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 6);
  425         CurrentPos = (uint32_T)((int32_T)CurrentPos + 1);
  426       }
  427   
  428       if (*emlrtBreakCheckR2012bFlagVar != 0) {
  429         emlrtBreakCheckR2012b(sp);
  430       }
  431     }
  432   
  433     if (covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 3, covrtLogMcdc
  434                    (&emlrtCoverageInstance, 0U, 0U, 2, !covrtLogCond
  435                     (&emlrtCoverageInstance, 0U, 0U, 3, Error)))) {
  436       covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 7);
  437       (*Vcount)++;
  438       maxdimlen = V->size[0];
  439       i0 = (int32_T)*Vcount;
  440       if (!((i0 >= 1) && (i0 <= maxdimlen))) {
  441         emlrtDynamicBoundsCheckR2012b(i0, 1, maxdimlen, &e_emlrtBCI, sp);
  442       }
  443   
  444       maxdimlen = i0 - 1;
  445       V->data[maxdimlen] = StartPos;
  446       V->data[maxdimlen + V->size[0]] = (real_T)CurrentPos - 2.0;
  447   
  448       /* was -1 */
  449     }
  450   
  451     emxInit_int32_T1(sp, &r0, 2, &emlrtRTEI, true);
  452     covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 8);
  453     anew = *Vcount + 1.0;
  454     i0 = V->size[0];
  455     i1 = r0->size[0] * r0->size[1];
  456     r0->size[0] = 1;
  457     r0->size[1] = (int32_T)muDoubleScalarFloor((real_T)i0 - anew) + 1;
  458     emxEnsureCapacity(sp, (emxArray__common *)r0, i1, (int32_T)sizeof(int32_T),
  459                       &emlrtRTEI);
  460     maxdimlen = (int32_T)muDoubleScalarFloor((real_T)i0 - anew);
  461     for (i0 = 0; i0 <= maxdimlen; i0++) {
  462       r0->data[r0->size[0] * i0] = (int32_T)(anew + (real_T)i0);
  463     }
  464   
  465     emxInit_real_T1(sp, &L, 1, &e_emlrtRTEI, true);
  466     st.site = &d_emlrtRSI;
  467     nullAssignment(&st, V, r0);
  468   
  469     /* here we have to collect the array indeed!!! */
  470     i0 = V->size[0];
  471     i1 = V->size[0];
  472     if (i0 != i1) {
  473       emlrtSizeEqCheck1DR2012b(i0, i1, &j_emlrtECI, sp);
  474     }
  475   
  476     maxdimlen = V->size[0];
  477     i0 = L->size[0];
  478     L->size[0] = maxdimlen;
  479     emxEnsureCapacity(sp, (emxArray__common *)L, i0, (int32_T)sizeof(real_T),
  480                       &emlrtRTEI);
  481     for (i0 = 0; i0 < maxdimlen; i0++) {
  482       L->data[i0] = (V->data[i0 + V->size[0]] - V->data[i0]) + 1.0;
  483     }
  484   
  485     emxInit_uint8_T(sp, &Af, 1, &f_emlrtRTEI, true);
  486     st.site = &e_emlrtRSI;
  487     Af_length = sum(&st, L);
  488     i0 = Af->size[0];
  489     if (!(Af_length >= 0.0)) {
  490       emlrtNonNegativeCheckR2012b(Af_length, &c_emlrtDCI, sp);
  491     }
  492   
  493     anew = Af_length;
  494     if (anew != (int32_T)muDoubleScalarFloor(anew)) {
  495       emlrtIntegerCheckR2012b(anew, &b_emlrtDCI, sp);
  496     }
  497   
  498     Af->size[0] = (int32_T)anew;
  499     emxEnsureCapacity(sp, (emxArray__common *)Af, i0, (int32_T)sizeof(uint8_T),
  500                       &emlrtRTEI);
  501     if (!(Af_length >= 0.0)) {
  502       emlrtNonNegativeCheckR2012b(Af_length, &c_emlrtDCI, sp);
  503     }
  504   
  505     if (anew != (int32_T)muDoubleScalarFloor(anew)) {
  506       emlrtIntegerCheckR2012b(anew, &b_emlrtDCI, sp);
  507     }
  508   
  509     maxdimlen = (int32_T)anew;
  510     for (i0 = 0; i0 < maxdimlen; i0++) {
  511       Af->data[i0] = 0;
  512     }
  513   
  514     Counter = 0.0;
  515     I_t = 0;
  516     emxInit_real_T(sp, &y, 2, &emlrtRTEI, true);
  517     while (I_t <= V->size[0] - 1) {
  518       covrtLogFor(&emlrtCoverageInstance, 0U, 0U, 0, 1);
  519       covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 9);
  520       i0 = V->size[0];
  521       i1 = I_t + 1;
  522       if (!((i1 >= 1) && (i1 <= i0))) {
  523         emlrtDynamicBoundsCheckR2012b(i1, 1, i0, &d_emlrtBCI, sp);
  524       }
  525   
  526       i0 = V->size[0];
  527       i1 = I_t + 1;
  528       if (!((i1 >= 1) && (i1 <= i0))) {
  529         emlrtDynamicBoundsCheckR2012b(i1, 1, i0, &c_emlrtBCI, sp);
  530       }
  531   
  532       if (V->data[I_t] > V->data[I_t + V->size[0]]) {
  533         i0 = 0;
  534         i2 = 0;
  535       } else {
  536         i0 = A->size[0];
  537         anew = V->data[I_t];
  538         if (anew != (int32_T)muDoubleScalarFloor(anew)) {
  539           emlrtIntegerCheckR2012b(anew, &emlrtDCI, sp);
  540         }
  541   
  542         i1 = (int32_T)anew;
  543         if (!((i1 >= 1) && (i1 <= i0))) {
  544           emlrtDynamicBoundsCheckR2012b(i1, 1, i0, &b_emlrtBCI, sp);
  545         }
  546   
  547         i0 = i1 - 1;
  548         i1 = A->size[0];
  549         anew = V->data[I_t + V->size[0]];
  550         if (anew != (int32_T)muDoubleScalarFloor(anew)) {
  551           emlrtIntegerCheckR2012b(anew, &emlrtDCI, sp);
  552         }
  553   
  554         i2 = (int32_T)anew;
  555         if (!((i2 >= 1) && (i2 <= i1))) {
  556           emlrtDynamicBoundsCheckR2012b(i2, 1, i1, &b_emlrtBCI, sp);
  557         }
  558       }
  559   
  560       st.site = &f_emlrtRSI;
  561       i1 = L->size[0];
  562       nm1d2 = I_t + 1;
  563       if (!((nm1d2 >= 1) && (nm1d2 <= i1))) {
  564         emlrtDynamicBoundsCheckR2012b(nm1d2, 1, i1, &emlrtBCI, &st);
  565       }
  566   
  567       b_st.site = &fb_emlrtRSI;
  568       c_st.site = &gb_emlrtRSI;
  569       if (muDoubleScalarIsNaN(L->data[I_t])) {
  570         n = 1;
  571         anew = rtNaN;
  572         apnd = L->data[I_t];
  573         overflow = false;
  574       } else if (L->data[I_t] < 1.0) {
  575         n = 0;
  576         anew = 1.0;
  577         apnd = L->data[I_t];
  578         overflow = false;
  579       } else if (muDoubleScalarIsInf(L->data[I_t])) {
  580         n = 1;
  581         anew = rtNaN;
  582         apnd = L->data[I_t];
  583         overflow = (1.0 == L->data[I_t]);
  584         overflow = !overflow;
  585       } else {
  586         anew = 1.0;
  587         ndbl = muDoubleScalarFloor((L->data[I_t] - 1.0) + 0.5);
  588         apnd = 1.0 + ndbl;
  589         cdiff = (1.0 + ndbl) - L->data[I_t];
  590         absb = muDoubleScalarAbs(L->data[I_t]);
  591         if (muDoubleScalarAbs(cdiff) < 4.4408920985006262E-16 * muDoubleScalarMax
  592             (1.0, absb)) {
  593           ndbl++;
  594           apnd = L->data[I_t];
  595         } else if (cdiff > 0.0) {
  596           apnd = 1.0 + (ndbl - 1.0);
  597         } else {
  598           ndbl++;
  599         }
  600   
  601         overflow = (2.147483647E+9 < ndbl);
  602         if (ndbl >= 0.0) {
  603           n = (int32_T)ndbl;
  604         } else {
  605           n = 0;
  606         }
  607       }
  608   
  609       d_st.site = &hb_emlrtRSI;
  610       if (!overflow) {
  611       } else {
  612         emlrtErrorWithMessageIdR2012b(&d_st, &m_emlrtRTEI, "Coder:MATLAB:pmaxsize",
  613           0);
  614       }
  615   
  616       i1 = y->size[0] * y->size[1];
  617       y->size[0] = 1;
  618       y->size[1] = n;
  619       emxEnsureCapacity(&c_st, (emxArray__common *)y, i1, (int32_T)sizeof(real_T),
  620                         &emlrtRTEI);
  621       if (n > 0) {
  622         y->data[0] = anew;
  623         if (n > 1) {
  624           y->data[n - 1] = apnd;
  625           nm1d2 = (n - 1) / 2;
  626           d_st.site = &ib_emlrtRSI;
  627           for (maxdimlen = 1; maxdimlen < nm1d2; maxdimlen++) {
  628             y->data[maxdimlen] = anew + (real_T)maxdimlen;
  629             y->data[(n - maxdimlen) - 1] = apnd - (real_T)maxdimlen;
  630           }
  631   
  632           if (nm1d2 << 1 == n - 1) {
  633             y->data[nm1d2] = (anew + apnd) / 2.0;
  634           } else {
  635             y->data[nm1d2] = anew + (real_T)nm1d2;
  636             y->data[nm1d2 + 1] = apnd - (real_T)nm1d2;
  637           }
  638         }
  639       }
  640   
  641       i1 = r0->size[0] * r0->size[1];
  642       r0->size[0] = 1;
  643       r0->size[1] = y->size[1];
  644       emxEnsureCapacity(sp, (emxArray__common *)r0, i1, (int32_T)sizeof(int32_T),
  645                         &emlrtRTEI);
  646       n = Af->size[0];
  647       maxdimlen = y->size[0] * y->size[1];
  648       for (i1 = 0; i1 < maxdimlen; i1++) {
  649         anew = Counter + y->data[i1];
  650         if (anew != (int32_T)muDoubleScalarFloor(anew)) {
  651           emlrtIntegerCheckR2012b(anew, &d_emlrtDCI, sp);
  652         }
  653   
  654         nm1d2 = (int32_T)anew;
  655         if (!((nm1d2 >= 1) && (nm1d2 <= n))) {
  656           emlrtDynamicBoundsCheckR2012b(nm1d2, 1, n, &i_emlrtBCI, sp);
  657         }
  658   
  659         r0->data[i1] = nm1d2;
  660       }
  661   
  662       i1 = r0->size[1];
  663       nm1d2 = i2 - i0;
  664       if (i1 != nm1d2) {
  665         emlrtSizeEqCheck1DR2012b(i1, nm1d2, &i_emlrtECI, sp);
  666       }
  667   
  668       maxdimlen = i2 - i0;
  669       for (i1 = 0; i1 < maxdimlen; i1++) {
  670         Af->data[r0->data[r0->size[0] * i1] - 1] = A->data[i0 + i1];
  671       }
  672   
  673       i0 = L->size[0];
  674       if (!((I_t + 1 >= 1) && (I_t + 1 <= i0))) {
  675         emlrtDynamicBoundsCheckR2012b(I_t + 1, 1, i0, &j_emlrtBCI, sp);
  676       }
  677   
  678       Counter += L->data[I_t];
  679       I_t++;
  680       if (*emlrtBreakCheckR2012bFlagVar != 0) {
  681         emlrtBreakCheckR2012b(sp);
  682       }
  683     }
  684   
  685     emxFree_int32_T(&r0);
  686     emxFree_real_T(&y);
  687     emxFree_real_T(&L);
  688     emxFree_real_T(&V);
  689     covrtLogFor(&emlrtCoverageInstance, 0U, 0U, 0, 0);
  690     covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 10);
  691     i0 = A->size[0];
  692     A->size[0] = Af->size[0];
  693     emxEnsureCapacity(sp, (emxArray__common *)A, i0, (int32_T)sizeof(uint8_T),
  694                       &emlrtRTEI);
  695     maxdimlen = Af->size[0];
  696     for (i0 = 0; i0 < maxdimlen; i0++) {
  697       A->data[i0] = Af->data[i0];
  698     }
  699   
  700     /* clear Af  */
  701     maxdimlen = (int32_T)muDoubleScalarRem(Af->size[0], 6.0);
  702     if (covrtLogIf(&emlrtCoverageInstance, 0U, 0U, 4, maxdimlen - 1 > -1)) {
  703       emxInit_int32_T1(sp, &b_Af, 2, &emlrtRTEI, true);
  704       covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 11);
  705       anew = (real_T)Af->size[0] - ((real_T)maxdimlen - 1.0);
  706       i0 = Af->size[0];
  707       i1 = b_Af->size[0] * b_Af->size[1];
  708       b_Af->size[0] = 1;
  709       b_Af->size[1] = (int32_T)((real_T)i0 - anew) + 1;
  710       emxEnsureCapacity(sp, (emxArray__common *)b_Af, i1, (int32_T)sizeof(int32_T),
  711                         &emlrtRTEI);
  712       maxdimlen = (int32_T)((real_T)i0 - anew);
  713       for (i0 = 0; i0 <= maxdimlen; i0++) {
  714         b_Af->data[b_Af->size[0] * i0] = (int32_T)(anew + (real_T)i0);
  715       }
  716   
  717       st.site = &g_emlrtRSI;
  718       b_nullAssignment(&st, A, b_Af);
  719       emxFree_int32_T(&b_Af);
  720     }
  721   
  722     emxFree_uint8_T(&Af);
  723     covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 12);
  724     anew = (real_T)A->size[0] / 6.0;
  725     st.site = &h_emlrtRSI;
  726     b_st.site = &jb_emlrtRSI;
  727     c_st.site = &mb_emlrtRSI;
  728     if (!(anew != muDoubleScalarFloor(anew))) {
  729     } else {
  730       emlrtErrorWithMessageIdR2012b(&c_st, &o_emlrtRTEI,
  731         "Coder:MATLAB:NonIntegerInput", 4, 12, MIN_int32_T, 12, MAX_int32_T);
  732     }
  733   
  734     maxdimlen = A->size[0];
  735     if (1 > maxdimlen) {
  736       maxdimlen = 1;
  737     }
  738   
  739     maxdimlen = muIntScalarMax_sint32(A->size[0], maxdimlen);
  740     if (6 > maxdimlen) {
  741       b_st.site = &kb_emlrtRSI;
  742       b_error(&b_st);
  743     }
  744   
  745     if ((int32_T)anew > maxdimlen) {
  746       b_st.site = &kb_emlrtRSI;
  747       b_error(&b_st);
  748     }
  749   
  750     emxInit_uint8_T1(&st, &b_y, 2, &emlrtRTEI, true);
  751     i0 = b_y->size[0] * b_y->size[1];
  752     b_y->size[0] = 6;
  753     b_y->size[1] = (int32_T)anew;
  754     emxEnsureCapacity(&st, (emxArray__common *)b_y, i0, (int32_T)sizeof(uint8_T),
  755                       &emlrtRTEI);
  756     if (A->size[0] == 6 * b_y->size[1]) {
  757     } else {
  758       emlrtErrorWithMessageIdR2012b(&st, &p_emlrtRTEI,
  759         "Coder:MATLAB:getReshapeDims_notSameNumel", 0);
  760     }
  761   
  762     b_st.site = &lb_emlrtRSI;
  763     overflow = ((!(1 > A->size[0])) && (A->size[0] > 2147483646));
  764     if (overflow) {
  765       c_st.site = &cb_emlrtRSI;
  766       check_forloop_overflow_error(&c_st);
  767     }
  768   
  769     for (maxdimlen = 0; maxdimlen + 1 <= A->size[0]; maxdimlen++) {
  770       b_y->data[maxdimlen] = A->data[maxdimlen];
  771     }
  772   
  773     emxInit_uint8_T1(&st, &b_A, 2, &c_emlrtRTEI, true);
  774     i0 = b_A->size[0] * b_A->size[1];
  775     b_A->size[0] = b_y->size[1];
  776     b_A->size[1] = 6;
  777     emxEnsureCapacity(sp, (emxArray__common *)b_A, i0, (int32_T)sizeof(uint8_T),
  778                       &emlrtRTEI);
  779     for (i0 = 0; i0 < 6; i0++) {
  780       maxdimlen = b_y->size[1];
  781       for (i1 = 0; i1 < maxdimlen; i1++) {
  782         b_A->data[i1 + b_A->size[0] * i0] = b_y->data[i0 + b_y->size[0] * i1];
  783       }
  784     }
  785   
  786     emxFree_uint8_T(&b_y);
  787     i0 = B->size[0] * B->size[1];
  788     B->size[0] = b_A->size[0];
  789     B->size[1] = 4;
  790     emxEnsureCapacity(sp, (emxArray__common *)B, i0, (int32_T)sizeof(real32_T),
  791                       &emlrtRTEI);
  792     maxdimlen = b_A->size[0] << 2;
  793     for (i0 = 0; i0 < maxdimlen; i0++) {
  794       B->data[i0] = 0.0F;
  795     }
  796   
  797     emxInit_uint16_T(sp, &a, 1, &emlrtRTEI, true);
  798     st.site = &i_emlrtRSI;
  799     maxdimlen = b_A->size[0];
  800     i0 = a->size[0];
  801     a->size[0] = maxdimlen;
  802     emxEnsureCapacity(&st, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  803                       &emlrtRTEI);
  804     for (i0 = 0; i0 < maxdimlen; i0++) {
  805       a->data[i0] = (uint16_T)(b_A->data[i0 + b_A->size[0]] & 112);
  806     }
  807   
  808     emxInit_uint16_T(&st, &r1, 1, &emlrtRTEI, true);
  809     b_st.site = &nb_emlrtRSI;
  810     nm1d2 = a->size[0];
  811     maxdimlen = a->size[0];
  812     i0 = r1->size[0];
  813     r1->size[0] = maxdimlen;
  814     emxEnsureCapacity(&b_st, (emxArray__common *)r1, i0, (int32_T)sizeof(uint16_T),
  815                       &b_emlrtRTEI);
  816     if (dimagree(r1, a)) {
  817     } else {
  818       emlrtErrorWithMessageIdR2012b(&b_st, &n_emlrtRTEI, "MATLAB:dimagree", 0);
  819     }
  820   
  821     maxdimlen = a->size[0];
  822     if (maxdimlen == 0) {
  823     } else {
  824       for (maxdimlen = 0; maxdimlen < nm1d2; maxdimlen++) {
  825         r1->data[maxdimlen] = (uint16_T)(a->data[maxdimlen] << 4);
  826       }
  827     }
  828   
  829     maxdimlen = b_A->size[0];
  830     i0 = a->size[0];
  831     a->size[0] = maxdimlen;
  832     emxEnsureCapacity(sp, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  833                       &emlrtRTEI);
  834     for (i0 = 0; i0 < maxdimlen; i0++) {
  835       a->data[i0] = b_A->data[i0];
  836     }
  837   
  838     emxInit_int32_T(sp, &r2, 1, &emlrtRTEI, true);
  839     i0 = r1->size[0];
  840     i1 = a->size[0];
  841     if (i0 != i1) {
  842       emlrtSizeEqCheck1DR2012b(i0, i1, &h_emlrtECI, sp);
  843     }
  844   
  845     nm1d2 = b_A->size[0];
  846     i0 = r2->size[0];
  847     r2->size[0] = nm1d2;
  848     emxEnsureCapacity(sp, (emxArray__common *)r2, i0, (int32_T)sizeof(int32_T),
  849                       &emlrtRTEI);
  850     for (i0 = 0; i0 < nm1d2; i0++) {
  851       r2->data[i0] = i0;
  852     }
  853   
  854     emxInit_real32_T(sp, &r3, 1, &emlrtRTEI, true);
  855     i0 = r3->size[0];
  856     r3->size[0] = r1->size[0];
  857     emxEnsureCapacity(sp, (emxArray__common *)r3, i0, (int32_T)sizeof(real32_T),
  858                       &emlrtRTEI);
  859     maxdimlen = r1->size[0];
  860     for (i0 = 0; i0 < maxdimlen; i0++) {
  861       r3->data[i0] = (uint16_T)((uint32_T)r1->data[i0] + a->data[i0]);
  862     }
  863   
  864     iv0[0] = r2->size[0];
  865     emlrtSubAssignSizeCheckR2012b(iv0, 1, *(int32_T (*)[1])r3->size, 1,
  866       &d_emlrtECI, sp);
  867     maxdimlen = r3->size[0];
  868     for (i0 = 0; i0 < maxdimlen; i0++) {
  869       B->data[r2->data[i0]] = r3->data[i0];
  870     }
  871   
  872     st.site = &j_emlrtRSI;
  873     maxdimlen = b_A->size[0];
  874     i0 = a->size[0];
  875     a->size[0] = maxdimlen;
  876     emxEnsureCapacity(&st, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  877                       &emlrtRTEI);
  878     for (i0 = 0; i0 < maxdimlen; i0++) {
  879       a->data[i0] = (uint16_T)(b_A->data[i0 + b_A->size[0]] & 7);
  880     }
  881   
  882     b_st.site = &nb_emlrtRSI;
  883     nm1d2 = a->size[0];
  884     maxdimlen = a->size[0];
  885     i0 = r1->size[0];
  886     r1->size[0] = maxdimlen;
  887     emxEnsureCapacity(&b_st, (emxArray__common *)r1, i0, (int32_T)sizeof(uint16_T),
  888                       &b_emlrtRTEI);
  889     if (dimagree(r1, a)) {
  890     } else {
  891       emlrtErrorWithMessageIdR2012b(&b_st, &n_emlrtRTEI, "MATLAB:dimagree", 0);
  892     }
  893   
  894     maxdimlen = a->size[0];
  895     if (maxdimlen == 0) {
  896     } else {
  897       for (maxdimlen = 0; maxdimlen < nm1d2; maxdimlen++) {
  898         r1->data[maxdimlen] = (uint16_T)(a->data[maxdimlen] << 8);
  899       }
  900     }
  901   
  902     maxdimlen = b_A->size[0];
  903     i0 = a->size[0];
  904     a->size[0] = maxdimlen;
  905     emxEnsureCapacity(sp, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  906                       &emlrtRTEI);
  907     for (i0 = 0; i0 < maxdimlen; i0++) {
  908       a->data[i0] = b_A->data[i0 + (b_A->size[0] << 1)];
  909     }
  910   
  911     i0 = r1->size[0];
  912     i1 = a->size[0];
  913     if (i0 != i1) {
  914       emlrtSizeEqCheck1DR2012b(i0, i1, &g_emlrtECI, sp);
  915     }
  916   
  917     maxdimlen = B->size[0];
  918     i0 = r2->size[0];
  919     r2->size[0] = maxdimlen;
  920     emxEnsureCapacity(sp, (emxArray__common *)r2, i0, (int32_T)sizeof(int32_T),
  921                       &emlrtRTEI);
  922     for (i0 = 0; i0 < maxdimlen; i0++) {
  923       r2->data[i0] = i0;
  924     }
  925   
  926     i0 = r3->size[0];
  927     r3->size[0] = r1->size[0];
  928     emxEnsureCapacity(sp, (emxArray__common *)r3, i0, (int32_T)sizeof(real32_T),
  929                       &emlrtRTEI);
  930     maxdimlen = r1->size[0];
  931     for (i0 = 0; i0 < maxdimlen; i0++) {
  932       r3->data[i0] = (uint16_T)((uint32_T)r1->data[i0] + a->data[i0]);
  933     }
  934   
  935     iv1[0] = r2->size[0];
  936     emlrtSubAssignSizeCheckR2012b(iv1, 1, *(int32_T (*)[1])r3->size, 1,
  937       &c_emlrtECI, sp);
  938     maxdimlen = r3->size[0];
  939     for (i0 = 0; i0 < maxdimlen; i0++) {
  940       B->data[r2->data[i0] + B->size[0]] = r3->data[i0];
  941     }
  942   
  943     st.site = &k_emlrtRSI;
  944     maxdimlen = b_A->size[0];
  945     i0 = a->size[0];
  946     a->size[0] = maxdimlen;
  947     emxEnsureCapacity(&st, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  948                       &emlrtRTEI);
  949     for (i0 = 0; i0 < maxdimlen; i0++) {
  950       a->data[i0] = (uint16_T)(b_A->data[i0 + (b_A->size[0] << 2)] & 112);
  951     }
  952   
  953     b_st.site = &nb_emlrtRSI;
  954     nm1d2 = a->size[0];
  955     maxdimlen = a->size[0];
  956     i0 = r1->size[0];
  957     r1->size[0] = maxdimlen;
  958     emxEnsureCapacity(&b_st, (emxArray__common *)r1, i0, (int32_T)sizeof(uint16_T),
  959                       &b_emlrtRTEI);
  960     if (dimagree(r1, a)) {
  961     } else {
  962       emlrtErrorWithMessageIdR2012b(&b_st, &n_emlrtRTEI, "MATLAB:dimagree", 0);
  963     }
  964   
  965     maxdimlen = a->size[0];
  966     if (maxdimlen == 0) {
  967     } else {
  968       for (maxdimlen = 0; maxdimlen < nm1d2; maxdimlen++) {
  969         r1->data[maxdimlen] = (uint16_T)(a->data[maxdimlen] << 4);
  970       }
  971     }
  972   
  973     maxdimlen = b_A->size[0];
  974     i0 = a->size[0];
  975     a->size[0] = maxdimlen;
  976     emxEnsureCapacity(sp, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
  977                       &emlrtRTEI);
  978     for (i0 = 0; i0 < maxdimlen; i0++) {
  979       a->data[i0] = b_A->data[i0 + b_A->size[0] * 3];
  980     }
  981   
  982     i0 = r1->size[0];
  983     i1 = a->size[0];
  984     if (i0 != i1) {
  985       emlrtSizeEqCheck1DR2012b(i0, i1, &f_emlrtECI, sp);
  986     }
  987   
  988     maxdimlen = B->size[0];
  989     i0 = r2->size[0];
  990     r2->size[0] = maxdimlen;
  991     emxEnsureCapacity(sp, (emxArray__common *)r2, i0, (int32_T)sizeof(int32_T),
  992                       &emlrtRTEI);
  993     for (i0 = 0; i0 < maxdimlen; i0++) {
  994       r2->data[i0] = i0;
  995     }
  996   
  997     i0 = r3->size[0];
  998     r3->size[0] = r1->size[0];
  999     emxEnsureCapacity(sp, (emxArray__common *)r3, i0, (int32_T)sizeof(real32_T),
 1000                       &emlrtRTEI);
 1001     maxdimlen = r1->size[0];
 1002     for (i0 = 0; i0 < maxdimlen; i0++) {
 1003       r3->data[i0] = (uint16_T)((uint32_T)r1->data[i0] + a->data[i0]);
 1004     }
 1005   
 1006     iv2[0] = r2->size[0];
 1007     emlrtSubAssignSizeCheckR2012b(iv2, 1, *(int32_T (*)[1])r3->size, 1,
 1008       &b_emlrtECI, sp);
 1009     maxdimlen = r3->size[0];
 1010     for (i0 = 0; i0 < maxdimlen; i0++) {
 1011       B->data[r2->data[i0] + (B->size[0] << 1)] = r3->data[i0];
 1012     }
 1013   
 1014     st.site = &l_emlrtRSI;
 1015     maxdimlen = b_A->size[0];
 1016     i0 = a->size[0];
 1017     a->size[0] = maxdimlen;
 1018     emxEnsureCapacity(&st, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
 1019                       &emlrtRTEI);
 1020     for (i0 = 0; i0 < maxdimlen; i0++) {
 1021       a->data[i0] = (uint16_T)(b_A->data[i0 + (b_A->size[0] << 2)] & 7);
 1022     }
 1023   
 1024     b_st.site = &nb_emlrtRSI;
 1025     nm1d2 = a->size[0];
 1026     maxdimlen = a->size[0];
 1027     i0 = r1->size[0];
 1028     r1->size[0] = maxdimlen;
 1029     emxEnsureCapacity(&b_st, (emxArray__common *)r1, i0, (int32_T)sizeof(uint16_T),
 1030                       &b_emlrtRTEI);
 1031     if (dimagree(r1, a)) {
 1032     } else {
 1033       emlrtErrorWithMessageIdR2012b(&b_st, &n_emlrtRTEI, "MATLAB:dimagree", 0);
 1034     }
 1035   
 1036     maxdimlen = a->size[0];
 1037     if (maxdimlen == 0) {
 1038     } else {
 1039       for (maxdimlen = 0; maxdimlen < nm1d2; maxdimlen++) {
 1040         r1->data[maxdimlen] = (uint16_T)(a->data[maxdimlen] << 8);
 1041       }
 1042     }
 1043   
 1044     maxdimlen = b_A->size[0];
 1045     i0 = a->size[0];
 1046     a->size[0] = maxdimlen;
 1047     emxEnsureCapacity(sp, (emxArray__common *)a, i0, (int32_T)sizeof(uint16_T),
 1048                       &emlrtRTEI);
 1049     for (i0 = 0; i0 < maxdimlen; i0++) {
 1050       a->data[i0] = b_A->data[i0 + b_A->size[0] * 5];
 1051     }
 1052   
 1053     i0 = r1->size[0];
 1054     i1 = a->size[0];
 1055     if (i0 != i1) {
 1056       emlrtSizeEqCheck1DR2012b(i0, i1, &e_emlrtECI, sp);
 1057     }
 1058   
 1059     maxdimlen = B->size[0];
 1060     i0 = r2->size[0];
 1061     r2->size[0] = maxdimlen;
 1062     emxEnsureCapacity(sp, (emxArray__common *)r2, i0, (int32_T)sizeof(int32_T),
 1063                       &emlrtRTEI);
 1064     for (i0 = 0; i0 < maxdimlen; i0++) {
 1065       r2->data[i0] = i0;
 1066     }
 1067   
 1068     i0 = r3->size[0];
 1069     r3->size[0] = r1->size[0];
 1070     emxEnsureCapacity(sp, (emxArray__common *)r3, i0, (int32_T)sizeof(real32_T),
 1071                       &emlrtRTEI);
 1072     maxdimlen = r1->size[0];
 1073     for (i0 = 0; i0 < maxdimlen; i0++) {
 1074       r3->data[i0] = (uint16_T)((uint32_T)r1->data[i0] + a->data[i0]);
 1075     }
 1076   
 1077     emxFree_uint16_T(&a);
 1078     emxFree_uint16_T(&r1);
 1079     iv3[0] = r2->size[0];
 1080     emlrtSubAssignSizeCheckR2012b(iv3, 1, *(int32_T (*)[1])r3->size, 1, &emlrtECI,
 1081       sp);
 1082     maxdimlen = r3->size[0];
 1083     for (i0 = 0; i0 < maxdimlen; i0++) {
 1084       B->data[r2->data[i0] + B->size[0] * 3] = r3->data[i0];
 1085     }
 1086   
 1087     emxFree_real32_T(&r3);
 1088     emxFree_int32_T(&r2);
 1089     maxdimlen = b_A->size[0];
 1090     i0 = A->size[0];
 1091     A->size[0] = maxdimlen;
 1092     emxEnsureCapacity(sp, (emxArray__common *)A, i0, (int32_T)sizeof(uint8_T),
 1093                       &emlrtRTEI);
 1094     for (i0 = 0; i0 < maxdimlen; i0++) {
 1095       A->data[i0] = (uint8_T)(b_A->data[i0 + b_A->size[0]] & 8);
 1096     }
 1097   
 1098     emxFree_uint8_T(&b_A);
 1099     st.site = &m_emlrtRSI;
 1100     b_st.site = &nb_emlrtRSI;
 1101     nm1d2 = A->size[0];
 1102     maxdimlen = A->size[0];
 1103     i0 = Sync->size[0];
 1104     Sync->size[0] = maxdimlen;
 1105     emxEnsureCapacity(&b_st, (emxArray__common *)Sync, i0, (int32_T)sizeof(uint8_T),
 1106                       &b_emlrtRTEI);
 1107     if (b_dimagree(Sync, A)) {
 1108     } else {
 1109       emlrtErrorWithMessageIdR2012b(&b_st, &n_emlrtRTEI, "MATLAB:dimagree", 0);
 1110     }
 1111   
 1112     maxdimlen = A->size[0];
 1113     if (maxdimlen == 0) {
 1114     } else {
 1115       for (maxdimlen = 0; maxdimlen < nm1d2; maxdimlen++) {
 1116         Sync->data[maxdimlen] = (uint8_T)((uint32_T)A->data[maxdimlen] >> 3);
 1117       }
 1118     }
 1119   
 1120     emxFree_uint8_T(&A);
 1121   
 1122     /*  clear A; */
 1123     emlrtHeapReferenceStackLeaveFcnR2012b(sp);
 1124   }
 1125   
 1126   /* End of code generation (Datalogger4ChConverter_ErrInsensitiveSound.c) */
 1127