30 lines
682 B
C
30 lines
682 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define MAX_SAMPLES 192
|
|
#define MAX_TEMP 40
|
|
|
|
float array_t[MAX_SAMPLES];
|
|
int i=0;
|
|
|
|
void main(void){
|
|
for (i=0;i<MAX_SAMPLES; i++) {array_t[i]=0;}
|
|
|
|
srand(28);
|
|
for (i=0;i<MAX_SAMPLES; i++) {
|
|
array_t[i]=(float)rand()/(float)(RAND_MAX)*MAX_TEMP;
|
|
printf("[%2.2f,%2.2f] \n", (float)(i)/(float)(MAX_SAMPLES/24), array_t[i]);
|
|
}
|
|
|
|
FILE *fptr = fopen("data.html", "w");
|
|
fprintf(fptr,"var array = [");
|
|
for (i=0;i<MAX_SAMPLES; i++) {
|
|
fprintf(fptr,"[%2.2f,%2.2f]", (float)(i)/(float)(MAX_SAMPLES/24), array_t[i]);
|
|
if (i<(MAX_SAMPLES-1)){
|
|
fprintf(fptr,",");
|
|
}
|
|
}
|
|
fprintf(fptr,"]");
|
|
fclose(fptr);
|
|
|
|
} |