IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

convertir code C en MATLAB


Sujet :

MATLAB

  1. #21
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2013
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2013
    Messages : 26
    Points : 14
    Points
    14
    Par défaut
    Bonjour , J'ai modifier le code mais matlab m'affiche des erreur !!!!

    le code group.c modifier
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    /*****************************************************************/
           /* This program is for grouping in speech segregation using         */
           /* Terman-Wang oscillators. These equations are solved           */
           /* in the sigular limit (Linsay-Wang), and the potential is      */
           /* included here. Real signals.  by DeLiang Wang, 8/97           */
           /*****************************************************************/
    #include "mex.h"
    #include "group.h"
     
    #define MAXVAL 32768.0
                   /* 2147483648.0 or 32768.0,machine (HP or SUN) dependable*/
    #define MAX 32767 /* 2147483647 or 32767, machine dependable */
     
    float Gamma = 6.5;         /* CAREFUL: this value offset Wz = 1.5 */
    float alpha = 5.0;
    float theta = -0.5;
    float lambda = 0.1;        /* rate of developing potential */
    float time = 0.0;          /* global time */
    float rnd(), getx(), getxx(), lateral();
    int Hp[N1][N2];        /* argument to the Heaviside for potential */
    int Num = 0, longseg;           /* number of major phase updates */
     
    float y[N1][N2],cubic[N1][N2],p[N1][N2],show[M][STEPS];
    float shows[Ms][STEPS], showp[Mp][STEPS];
    float W[N1][N2][N1];   /* strength of the interactions */
    float input[N1][N2];  /* overall input an oscillator receives */
    float We = 0.5, Wi = -0.5; /* We: total excit weight; C: count */
    int branch[N1][N2], ext[N1][N2], ext2[N1][N2], segment[SEG][2];
    int speech[N1][N2], phone[N1][N2]; /* for storing and display */
    int chance[SEG], jumpup[SEG];
         /* branch: keeps track of whether an oscillator is on LB or RB */
         /* ext2: segment information */
     
    void inputs(void)
    {
       FILE *fopen(), *finput, *fout;
       int i, j, k, l, maxy, temp, temp1, temp2, label[N1];
       int width, height, c;
       char magic[25];
       float stim = 0.2;
     
       for (i = 0; i < N1; i++) 
         for (j = 0; j < N2; j++)
           input[i][j] = -10.0;
     
       finput = fopen("v8n6.pitchmask.pgm", "r");
       fscanf(finput,"%s\n%d %d\n%d\n",magic,&width,&height,&c);
       for(j=0;j<N2;j++) 
         for(i=0;i<N1;i++)
            fscanf(finput, "%d",&ext[i][j]); 
     
       finput = fopen("v8n6-seg.pgm", "r");
       fscanf(finput,"%s\n%d %d\n%d\n",magic,&width,&height,&c);
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fscanf(finput, "%d",&ext2[N1-1-i][j]); 
     
       /* for storing and display purposes */
       finput = fopen("Snap1", "r");
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fscanf(finput, "%d",&speech[i][j]); 
       finput = fopen("Snap2", "r");
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fscanf(finput, "%d",&phone[i][j]); 
     
       /* masking by segments */
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++) 
           if (ext2[i][j] == 0)
    	 ext[i][j] = 0;
     
       /*
       fout = fopen("phone1", "w");
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fprintf(fout, "%d ",ext[i][j]); 
       fclose(fout);
     
       fout = fopen("phone2", "w");
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fprintf(fout, "%d ",ext2[i][j]); 
       fclose(fout);
       */
     
       /* identify longest segment and clip accordingly */
       for (i = 0; i < SEG; i++) {
         segment[i][0] = N2;
         segment[i][1] = 0;
       }
     
       for (i = 0; i < N1; i++)
         for (j = 0; j < N2; j++) {
           temp = ext2[i][j];
           if (segment[temp][0] > j)
    	 segment[temp][0] = j;
           if (segment[temp][1] < j)
    	 segment[temp][1] = j;
         }
     
       maxy = 0;
       for (i = 1; i < SEG; i++) /* excluding the background */
         if (segment[i][1] - segment[i][0] + 1 > maxy) {
           maxy = segment[i][1] - segment[i][0] + 1;
           longseg = i;
         }
       mexprintf("longest segment is %d, and has columns %d\n", longseg, maxy);
     
       for (j = 0; j < segment[longseg][0]; j++)
         for (i = 0; i < N1; i++)
           ext[i][j] = 0;
       for (j = segment[longseg][1] + 1; j < N2; j++)
         for (i = 0; i < N1; i++)
           ext[i][j] = 0;
     
       /* recompute segment lengths */
       k = segment[longseg][0]; l = segment[longseg][1];
       for (i = 0; i < SEG; i++) {
         segment[i][0] = N2;
         segment[i][1] = 0;
       }
     
       for (i = 0; i < N1; i++)
         for (j = k; j <= l; j++) {
           temp = ext2[i][j];
           if (segment[temp][0] > j)
    	 segment[temp][0] = j;
           if (segment[temp][1] < j)
    	 segment[temp][1] = j;
         }
     
       for (i = 1; i < SEG; i++)
         if (segment[i][1] - segment[i][0] < 2) { /* threshold out <3-frame seg */
           for(k=0;k<N1;k++)                      /* caused by clipping         */ 
             for(l=0;l<N2;l++)
               if (ext2[k][l] == i)
    	     ext[k][l] = 0;
         }
     
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
           if (ext[i][j] > 0)
    	 input[i][j] = stim;
     
     
       /* smoothen within each column of each segment */
       for (j = segment[longseg][0]; j <= segment[longseg][1]; j++) {
         for (i = 0; i < N1; i++)
           label[i] = 0;
     
         for (i = 0; i < N1; i++)
           if (label[i] == 0 && ext[i][j] > 0) {
    	 temp = ext2[i][j]; temp1 = temp2 = 0;
    	 for (k = 0; k < N1; k++)
    	   if (ext2[k][j] == temp) {
    	     if (ext[k][j] == 1)
    	       temp1++;
    	     else if (ext[k][j] == 2)
    	       temp2++;
    	   }
    	 for (k = 0; k < N1; k++)
    	   if (ext2[k][j] == temp && ext[k][j] > 0) {
    	     label[k] = 1;
    	     if (temp1 > temp2)
    	       ext[k][j] = 1;
                 else
    	       ext[k][j] = 2;
    	   }
           }
       }
     
     
       fout = fopen("phone3", "w");
       for(i=0;i<N1;i++)
         for(j=0;j<N2;j++)
            fprintf(fout, "%d ",ext[i][j]); 
       fclose(fout);
     
    /* high "potential" */
       input[8][N2/2] = 0.21; /* 20 for v3n6; 8 for v8n6 */
     
       mexprintf("The segment number with high potential is %d\n", ext2[8][N2/2]);
    }
     
    void connections(void)
    {
       int i, j, k; /* e: excitatory; i: inhibitory; l: lateral */
     
       for (i = 0; i < N1; i++) {
         for (j = segment[longseg][0]; j <= segment[longseg][1]; j++) {
           for (k = 0; k < N1; k++) /* initialize connections */
    	 W[i][j][k] = 0.0;
           if (ext[i][j] == 1) {
             for (k = 0; k < N1; k++) 
    	   if (k != i && ext2[k][j] != ext2[i][j] ) {
    	     if (ext[k][j] == 1)
    	       W[i][j][k] = We;
                 else if (ext[k][j] == 2)
    	       W[i][j][k] = Wi;
    	   }
           }
           else if (ext[i][j] == 2)
             for (k = 0; k < N1; k++) 
    	   if (k != i && ext2[k][j] != ext2[i][j] ) {
      	     if (ext[k][j] == 2)
    	       W[i][j][k] = We;
                 else if (ext[k][j] == 1)
    	       W[i][j][k] = Wi;
    	   }
         }
       }
     
       mexprintf("weights are \n");
       mexprintf("weights are \n");
       mexprintf("W[0][0] are %f %f\n", W[0][0][1], W[0][0][2]);
       mexprintf("W[1][4] are %f %f\n", W[1][4][0], W[1][4][2]);
       mexprintf("W[2][6] are %f %f\n", W[2][6][0], W[2][6][1]);
     
       mexprintf("\n");
    }
     
    void initiate(void)
    {
       int i,j,seed,counts,countp;  /* labels for setting up display intervals */
       float angle, temp;
     
       mexprintf("Input a seed now\n"); /* 2342 for potential; 111 no potent.*/
       scanf("%d",&seed); 
       srand(seed); 
     
    /* randomize the initial phases */
       temp = 2.0*Gamma*rnd();
       for (i = 0; i < N1; i++)
         for (j = 0; j < N2; j++) {  /* Initial phases */
           if (ext[i][j] > 0)
    	 y[i][j] = temp + input[i][j];
           else
    	 y[i][j] = 2.0*Gamma*rnd();
     
           branch[i][j] = 0;
     
           /*
           p[i][j] = 0.0;
     
           Hp[i][j] = 0;
           */
     
           cubic[i][j] = input[i][j];
         }
     
       for (i = 0; i < SEG; i++) {
         chance[i] = 1;
         jumpup[i] = 0;
       }
     
     /* initial display values for 1D */
       for (i = 0; i < N1; i = i+2)
           show[i/2][0] = getxx(y[i][COL]-cubic[i][COL], 0);
     
     /* initial display values for two storage arrays */
       counts = countp = 0; /* for collecting display data for two streams */
       for (i = 0; i < N1; i++)
         for (j = 0; j < N2; j++) {
    	if (speech[i][j] && (counts%20 == 0))
              shows[counts/20][0] = getxx(y[i][j]-cubic[i][j],0);
    	else if (phone[i][j] && (countp%20 == 0))
              showp[countp/20][0] = getxx(y[i][j]-cubic[i][j],0);
     
    	if (speech[i][j])
    	  counts++;
    	else if (phone[i][j])
    	  countp++;
         }
     
     /* initial display values for 2D */
       /*
       for (i = 0; i < N1; i++)
         for (j = 0; j < N2; j++)
           show[N2*i+j][0] = getxx(y[i][j]-cubic[i][j], 0);
       */
    }
     
    findtmin(tmin, mu, ilead, jlead) 
      float *tmin, *mu;
      int *ilead, *jlead;
         /* Find shortest time-to-knee when no oscillator is ready to jump */
    {
       int i, j, il, jl, ir, jr;
       float temp, minl = MAXVAL, minr = MAXVAL, yknee;
     
       for (i = 0; i < N1; i++)
         for (j = segment[longseg][0]; j <= segment[longseg][1]; j++) {
           if (branch[i][j]) {          /* on RB */
    	 yknee = (y[i][j]-2.0*Gamma)/(cubic[i][j]+4.0-2.0*Gamma);
    	 if (yknee < minr && yknee > 0.0)  /* exclude stable fixed point */
    	   {minr = yknee; ir = i; jr = j;}
           }
           else {                       /* on LB */
    	 yknee = y[i][j]/cubic[i][j];
    	 if (yknee < minl && yknee > 0.0)  /* exclude stable fixed point */
      	   {minl = yknee; il = i; jl = j;}
           }
         }
     
       if (minl < 1.0)
         {*tmin = 0.0; *mu = 1.0; *ilead = il; *jlead = jl;}
       else if (minr < 1.0)
         {*tmin = 0.0; *mu = 1.0; *ilead = ir; *jlead = jr;}
       else {
         *tmin = log(minl);
         *mu = minl;
         *ilead = il;
         *jlead = jl;
         temp = log(minr);
         if (temp < *tmin) {       
           *tmin = temp;
           *mu = minr;
           *ilead = ir; *jlead = jr;
         } 
       }
    }
     
    void jump(void)      /* activity at the jump (up or down) time */
    {       
       int i, j, k, l, count, jumped = 1, Tij = 2, flag = 1, cat[N1][N2];
                                                   /* Tij: permanent weight */
       int temp, curseg;
       float We1 = 4.0, We2 = 0.1;
     
       while (jumped) {
          jumped = 0;
          for (i = 0; i < N1; i++)
    	for (j = 0; j < N2; j++)
    	  cat[i][j] = 0;
     
          for (i = 0; i < N1; i++)
    	for (j = segment[longseg][0]; j <= segment[longseg][1]; j++) 
    	if (ext[i][j] > 0 && ext2[i][j] > 0) { 
                                                          /* compute net input */
    	  if (p[i][j] > theta)
    	                                      /* thrshld for exp(-alpha*t) */
    	    cubic[i][j] = input[i][j];
              else
    	    cubic[i][j] = baseline;
     
    	  /* update cubics within each segment */
    	  count = 0;
    	  curseg = ext2[i][j];
    	  for (k = segment[curseg][0]; k <= segment[curseg][1]; k++) {
    	    temp = 0;
    	    for (l = 0; l < N1; l++)
    	      if (ext2[l][k] == ext2[i][j] && branch[l][k])
    		temp = 1;
    	    if (temp == 1)
    	      count++;
    	  }
     
    	  temp = ext2[i][j];
              if (ext[i][j]>0 && count>(1+segment[temp][1]-segment[temp][0])/2)  
    	                           /* strict majarity rule: >; less >= (1+.) */
    	    cubic[i][j] += We1;
    	  else if (ext[i][j] > 0 
    		   && segment[temp][1] == segment[temp][0]+count*2-1) { 
    	                           /* break symmetry */
    	    if (chance[curseg])
    	      cubic[i][j] += We2;
    	    else
    	      cubic[i][j] += We1;
    	  }
    	  else if (ext[i][j] > 0 && count > 0)
    	    cubic[i][j] += We2;
     
    	  /* update cubics within each column */
    	  if (branch[i][j] == 0) 
    	    cubic[i][j] += lateral(i,j);
     
    	  if (!branch[i][j] && y[i][j]<cubic[i][j]+error) {  /* jump up */
      	        cat[i][j] = 1;
    		jumped = 1;
    		cubic[i][j] -= lateral(i,j);
    		jumpup[curseg] = 1;
    	  } else if (branch[i][j] && y[i][j]>cubic[i][j]+4.0-error) {
    	                                                     /* jump down */
    	        cat[i][j] = -1;
    		jumped = 1;
    		cubic[i][j] += lateral(i,j);
    	  }
     
          }
     
          for (i = 0; i < N1; i++)
    	for (j = 0; j < N2; j++) { /* update jumps */
    	  if (cat[i][j] > 0)
    	    branch[i][j] = 1;
    	  else if (cat[i][j] < 0)
    	    branch[i][j] = 0;
    	}
       }
     
       for (i = 1; i < SEG; i++)
         if (jumpup[i]) {
           temp = 0;
     
           for (k = segment[i][0]; k <= segment[i][1]; k++) 
    	 for (l = 0; l < N1; l++)
    	   if (ext2[l][k] == i && branch[l][k])
    	     temp = 1;
     
           if (temp == 0) {
    	 chance[i] = 1 - chance[i];
    	 jumpup[i] = 0;
           }
         }
     
    /* compute Hp[i][j] */
       /*
       for (i = 0; i < N1; i++)  
         for (j = 0; j < N2; j++) { 
           Hp[i][j] = 0;
           if (i-1 >= 0 && branch[i-1][j])
             Hp[i][j] += Tij;
           if (i+1 < N1 && branch[i+1][j])
    	 Hp[i][j] += Tij;
           if (j-1 >= 0 && branch[i][j-1])
    	 Hp[i][j] += Tij;
           if (j+1 < N2 && branch[i][j+1])
    	 Hp[i][j] += Tij;
     
           if (Hp[i][j] > 7)
    	 Hp[i][j] = 1;
           else 
    	 Hp[i][j] = 0;
         }
       */
    }
     
    void evaluate(void)
    {
       float intv, mu, current, length, xval, yval, angle, temp, cat;
       int ilead, jlead, num; /* leading oscillator, and no of jumpers */
       int counts, countp;    /* counts for speech and phone respectively */
       int i,j,step,bef,aft;  /* labels for setting up display intervals */
       FILE *outf, *fopen();
     
       outf = fopen("Out", "w");
       bef = 0;
       length = delta*(STEPS-1);      /* reduce one step to facilitate display */
       while (time < length) {
         findtmin(&intv, &mu, &ilead, &jlead);
     
         aft = (time+intv)/delta;
     
        /* store for display in 1d case*/
     
         for (step = bef; step < aft && step < STEPS-1; step++) {
           for (i = 0; i < N1; i = i+2) {
               temp = -((1.0+step)*delta - time);
    	   if (branch[i][COL])
    	     yval = (y[i][COL] - 2*Gamma)*exp(temp) + 2*Gamma - cubic[i][COL];
    	   else
    	     yval = y[i][COL]*exp(temp) - cubic[i][COL];
     
               show[i/2][step+1] = getxx(yval,branch[i][COL]);
           }
           counts = countp = 0; /* for collecting display data for two streams */
           for (i = 0; i < N1; i++)
             for (j = 0; j < N2; j++) {
    	   if (speech[i][j] && (counts%20 == 0)) {
                 temp = -((1.0+step)*delta - time);
    	     if (branch[i][j])
    	       yval = (y[i][j] - 2*Gamma)*exp(temp) + 2*Gamma - cubic[i][j];
    	     else
    	       yval = y[i][j]*exp(temp) - cubic[i][j];
     
                 shows[counts/20][step+1] = getxx(yval,branch[i][j]);
    	   } else if (phone[i][j] && (countp%20 == 0)) {
                 temp = -((1.0+step)*delta - time);
    	     if (branch[i][j])
    	       yval = (y[i][j] - 2*Gamma)*exp(temp) + 2*Gamma - cubic[i][j];
    	     else
    	       yval = y[i][j]*exp(temp) - cubic[i][j];
     
                 showp[countp/20][step+1] = getxx(yval,branch[i][j]);
    	   }
     
    	   if (speech[i][j])
    	     counts++;
    	   else if (phone[i][j])
    	     countp++;
             }
         }
     
     
        /* store for display in 2d case*/
    /*
         for (step = bef; step < aft && step < STEPS-1; step++) {
           for (i = 0; i < N1; i++)
             for (j = 0; j < N2; j++) {
               temp = -((1.0+step)*delta - time);
    	   if (branch[i][j])
    	     yval = (y[i][j] - 2*Gamma)*exp(temp) + 2*Gamma - cubic[i][j];
    	   else
    	     yval = y[i][j]*exp(temp) - cubic[i][j];
     
               show[N2*i+j][step+1] = getxx(yval,branch[i][j]);
             }
         }
    */
     
         for (i = 0; i < N1; i++) /* advance oscillators */
           for (j = 0; j < N2; j++) {
    	 if (branch[i][j])
    	   y[i][j] = (y[i][j]-2.0*Gamma)/mu + 2.0*Gamma;
    	 else
    	   y[i][j] = y[i][j]/mu;
           }
     
    /* update oscillator potential */
         /*
         for (i = 0; i < N1; i++) 
           for (j = 0; j < N2; j++)
    	 if (Hp[i][j] && input[i][j] > 0.0)
    	   p[i][j] = 1.0-(1.0-p[i][j])/mu;
     
         */
     
         if (branch[ilead][jlead]) {
           branch[ilead][jlead] = 0;
           /*       priming(jlead);*/
           cubic[ilead][jlead] += lateral(ilead,jlead);
         }
         else {
           branch[ilead][jlead] = 1;
           /*       priming(jlead);*/
           cubic[ilead][jlead] -= lateral(ilead,jlead);
         }
     
         jump();            /* fast time activity */
     
         Num++;
         mexprintf("Num = %d, time = %f, intv = %f\n", Num, time, intv);
     
         for(i=0;i<N1;i++)
           for(j=0;j<N2;j++)
             fprintf(outf, "%d ",branch[i][j]); 
     
         time += intv;      
         bef = aft;
       }
       fclose(outf);
    }
     
    void store(void)
    {
       int i,j,t,count;
       float max_v = 0.0, min_v = 0.0;
       FILE *outfile,*out,*fopen();
     
       outfile = fopen("Output", "w");
       out = fopen("NUMBER", "w");
       fprintf(out, "%d ", Num);
       mexprintf("The number of the segments/cycles is %d\n", Num);
     
       /*
       for (i = 0; i < M; i++) 
          for (t = 0; t < STEPS; t++)  {
            if (show[i][t] > max_v)
              max_v = show[i][t];
            if (show[i][t] < min_v)
              min_v = show[i][t];
          }
          */
       for (i = 0; i < Ms; i++) 
          for (t = 0; t < STEPS; t++)  {
            if (shows[i][t] > max_v)
              max_v = shows[i][t];
            if (shows[i][t] < min_v)
              min_v = shows[i][t];
          }
       for (i = 0; i < Mp; i++) 
          for (t = 0; t < STEPS; t++)  {
            if (showp[i][t] > max_v)
              max_v = showp[i][t];
            if (showp[i][t] < min_v)
              min_v = showp[i][t];
          }
     
    mexprintf("Maximum is %f,   Minimum is %f\n", max_v, min_v);
     
       for (i = 0; i < M; i++)
         for (t = 0; t < STEPS; t++)
           fprintf(outfile, "%f ", (show[i][t]-min_v)/(max_v-min_v));
       fclose(outfile); 
     
       /*
       outfile = fopen("Speech", "w");
       for (i = 0; i < Ms; i++)
         for (t = 0; t < STEPS; t++)
           fprintf(outfile, "%f ", (shows[i][t]-min_v)/(max_v-min_v));
       fclose(outfile); 
     
       outfile = fopen("Phone", "w");
       for (i = 0; i < Mp; i++)
         for (t = 0; t < STEPS; t++)
           fprintf(outfile, "%f ", (showp[i][t]-min_v)/(max_v-min_v));
       fclose(outfile); 
       */
       fclose(out);
    void mexFunction(int nlhs, mxArray *plhs[],
            int nrhs, const mxArray *prhs[])
    {
     
        inputs();
        connections();
        initiate();
        evaluate();
        store();
    }
     
    float rnd() /* returning a value in (0, 1) */
    {
       return(rand()/(MAXVAL - 1.0));
    }
     
    float lateral(i,j) /* determine lateral connections */
      int i, j;
    {
      int k;
      float temp1 = 0.0, temp2 = 0.0, base = 0.05;
     
      for (k = 0; k < N1; k++)
        if (k != i && ext2[k][j] != ext2[i][j] && branch[k][j] && ext[i][j] > 0) {
          if (W[i][j][k] > base)
    	temp1 = We;
          else if (W[i][j][k] < -base)
    	temp2 = Wi;
        }
      if (temp2 < -base)
        return(Wi);
      else if (temp1 > base)
        return(We);
      else return(0.0);
    }
     
    float getxx(y,br) /* br: branch */
      float y;
      int br;
    {
      float temp, cat;
     
      /* solving cubic equation */
      cat = -0.5*(y-2.0);
      if (y > 0.0 && y < 4.0) {
        temp = acos(cat);
        if (br)
          return(2*cos(temp/3.0));
        else
          return(2*cos(temp/3.0+0.66*3.1416));
      } else {
        temp = 0.5*sqrt(y*y-4.0*y);
        if (cat - temp > 0.0)
          return(pow(cat+temp,0.333) + pow(cat-temp,0.333));
        else if (cat + temp > 0.0)
          return(pow(cat+temp,0.333) - pow(-cat+temp,0.333));
        else
          return(-pow(-cat-temp,0.333) - pow(-cat+temp,0.333));
      }
    }  
     
    float getx(y,br) /* piecewise linear version */
      float y;
      int br;
    {
      if (y > 0.0 && y < 4.0) {
        if (br)
          return(-0.25*y+2.0);
        else
          return(-0.25*y-1.0);
      } else {
        if (y > 0.0)
          return(-0.25*y-1.0);
        else
          return(-0.25*y+2.0);
      }
    }
    l'erreur Matlab:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    mex group.c
    Warning group.c: 227  local `float angle' is not referenced 
    Warning group.c: 323  missing return value 
    Warning group.c: 442  local `int num' is not referenced 
    Warning group.c: 441  local `float cat' is not referenced 
    Warning group.c: 441  local `float angle' is not referenced 
    Warning group.c: 441  local `float xval' is not referenced 
    Warning group.c: 441  local `float current' is not referenced 
    Error group.c: 611  illegal statement termination 
    Error group.c: 611  skipping `void' 
    Error group.c: 611  illegal expression 
    Error group.c: 611  syntax error; found `nlhs' expecting `)' 
    Error group.c: 611  insufficient number of arguments to `mexFunction' 
    Error group.c: 611  syntax error; found `nlhs' expecting `;' 
    Error group.c: 611  undeclared identifier `nlhs' 
    Error group.c: 611  illegal use of type name `mxArray' 
    Error group.c: 611  undeclared identifier `plhs' 
    Error group.c: 611  illegal expression 
    Error group.c: 612  illegal expression 
    Error group.c: 612  syntax error; found `nrhs' expecting `]' 
    Error group.c: 612  type error: pointer expected 
    Error group.c: 612  operands of * have illegal types `incomplete struct mxArray_tag defined at C:\PROGRA~1\MATLAB\R2010A\extern\include\matrix.h 293' and `int' 
    Warning group.c: 612  reference to `incomplete struct mxArray_tag defined at C:\PROGRA~1\MATLAB\R2010A\extern\include\matrix.h 293' elided 
    Warning group.c: 612  Statement has no effect 
    Error group.c: 612  syntax error; found `nrhs' expecting `;' 
    Error group.c: 612  undeclared identifier `nrhs' 
    Error group.c: 612  illegal expression 
    Warning group.c: 612  Statement has no effect 
    Error group.c: 612  syntax error; found `mxArray' expecting `;' 
    Error group.c: 612  illegal use of type name `mxArray' 
    Error group.c: 612  undeclared identifier `prhs' 
    Error group.c: 612  too many errors 
     
      C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Compile of 'group.c' failed. 
     
    ??? Error using ==> mex at 222
    Unable to complete successfully.
     
    >> mex group.c
    Warning group.c: 227  local `float angle' is not referenced 
    Warning group.c: 323  missing return value 
    Warning group.c: 442  local `int num' is not referenced 
    Warning group.c: 441  local `float cat' is not referenced 
    Warning group.c: 441  local `float angle' is not referenced 
    Warning group.c: 441  local `float xval' is not referenced 
    Warning group.c: 441  local `float current' is not referenced 
    Error group.c: 611  illegal statement termination 
    Error group.c: 611  skipping `void' 
    Error group.c: 611  illegal expression 
    Error group.c: 611  syntax error; found `nlhs' expecting `)' 
    Error group.c: 611  insufficient number of arguments to `mexFunction' 
    Error group.c: 611  syntax error; found `nlhs' expecting `;' 
    Error group.c: 611  undeclared identifier `nlhs' 
    Error group.c: 611  illegal use of type name `mxArray' 
    Error group.c: 611  undeclared identifier `plhs' 
    Error group.c: 611  illegal expression 
    Error group.c: 612  illegal expression 
    Error group.c: 612  syntax error; found `nrhs' expecting `]' 
    Error group.c: 612  type error: pointer expected 
    Error group.c: 612  operands of * have illegal types `incomplete struct mxArray_tag defined at C:\PROGRA~1\MATLAB\R2010A\extern\include\matrix.h 293' and `int' 
    Warning group.c: 612  reference to `incomplete struct mxArray_tag defined at C:\PROGRA~1\MATLAB\R2010A\extern\include\matrix.h 293' elided 
    Warning group.c: 612  Statement has no effect 
    Error group.c: 612  syntax error; found `nrhs' expecting `;' 
    Error group.c: 612  undeclared identifier `nrhs' 
    Error group.c: 612  illegal expression 
    Warning group.c: 612  Statement has no effect 
    Error group.c: 612  syntax error; found `mxArray' expecting `;' 
    Error group.c: 612  illegal use of type name `mxArray' 
    Error group.c: 612  undeclared identifier `prhs' 
    Error group.c: 612  too many errors 
     
      C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Compile of 'group.c' failed.

  2. #22
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 318
    Points : 52 958
    Points
    52 958
    Par défaut
    L'information se trouve dans le message d'erreur :

    Error group.c: 611  illegal statement termination 
    Il manque une accolade fermante } juste avant la ligne 611 du fichier group.c

    D'autre part, il faut impérativement un P majuscule à mexPrintf

  3. #23
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2013
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2013
    Messages : 26
    Points : 14
    Points
    14
    Par défaut
    C'est bon Merci : )

Discussions similaires

  1. [Débutant] Convertir code Fortran en MATLAB
    Par zakmakaay9 dans le forum MATLAB
    Réponses: 10
    Dernier message: 25/02/2019, 18h11
  2. Code Ada et MATLAB
    Par coacoa dans le forum MATLAB
    Réponses: 1
    Dernier message: 15/02/2007, 09h57
  3. convertir code php en asp
    Par goaim dans le forum ASP
    Réponses: 1
    Dernier message: 19/10/2006, 16h53
  4. Convertir code C en delphi
    Par jt-tronix dans le forum Langage
    Réponses: 12
    Dernier message: 29/03/2006, 21h55
  5. convertir code clavier en caractère
    Par danyboy85 dans le forum Général JavaScript
    Réponses: 13
    Dernier message: 22/02/2006, 20h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo