-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_fltr.c
46 lines (36 loc) · 880 Bytes
/
v_fltr.c
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
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include "synth_wind.h"
//filter and separate velocity data based on states
float **v_fltr(float *v, int N, int *nf, int **st_lim, int term){
int i, j, *cnt;
float **res;
res = malloc(term*sizeof(res));
cnt = malloc(term*sizeof(int));
for(i=0; i<term; i++){
*(nf+i) = 0;
*(cnt+i) = 0;
}
for(i=0; i<N; i++)
for(j=0; j<term; j++)
if(*(v+i) >=*(*(st_lim+j)) && *(v+i) <=*(*(st_lim+j)+1))
(*(nf+j))++;
// for(i=0; i<term; i++)
for(i=0; i<term; i++)
*(res+i) = malloc(*(nf+i)*sizeof(float));
for(i=0; i<N; i++){
for(j=0; j<term; j++){
if(*(v+i) >=*(*(st_lim+j)) && *(v+i) <=*(*(st_lim+j)+1)){
*(*(res+j)+(*(cnt+j))) = *(v+i);
(*(cnt+j))++;
}
}
}
free(cnt);
// for(i=0; i<term; i++)
// printf("%d %d\n", i, *(nn+i));
return(res);
}