# The implementation of the two -order linear microcompany

2023-03-18

The implementation of the two -order linear microcompany

1. Classic Micro Division Y = (V (T) -V (T -T))/T. At the interval time T, it has an enlarged effect on noise, and it cannot be applied to the task.

2. Second -order linear micro -division

3. C program verification

``````#include <stdio.h>
#include <stdlib.h>
#include "math.h"
#include "stdlib.h"

#Define TS (double) (0.01) /*Sample steps* /
#Define Tn (double) (0.05) /*micro -divided steps* /

double erjie (double x1, double x2, double u)
{{
Double Ret;
Double Deta;

DETA = 1.0 / (TN * TN);
RET = DETA * (X1 -U) + X2 * 2 / TN;

Return -RET;
}

int Main ()
{{
int i = 0;
double tim, dv, ds;
double u_1;
double x1, x1_1, x2, x2_1;
File*fp,*fnp,*fdp;

x1 = 0;
x1_1 = 0;
x2 = 0;
x2_1 = 0;
srand (2);
if ((fp = fst_yuan.txt "," w+") == null)
{{
Printf ("FAIL to Open fst_yuan.txt \ n");
exit (0);
}

if (FNP = FOPEN ("FST_NOW.txt", "W+") == NULL)
{{
Printf ("government to open fst_now.txt \ n");
exit (0);
}
if (fdp = fopen ("fst_dev.txt", "w+") == null)
{{
Printf ("government to open fst_dev.txt \ n");
exit (0);
}

for (i = 0; I <1000; I ++)
{{
TIM = TS * (i+1);

ds = sin (tIM) + 0.05*(RAND ()/32768.0);/*Simulated noise*/
dv = cos (tim); /*ideal differential differential curve* /

x1_1 = x1 + ts*x2; /*micro -tracking* /
x2_1 = x2 + TS * Erjie (X1, X2, DS);

fprintf (fp, " %. 10lf %.10lf \ n", ds, dv); /*Save to the file. Draw curve through Matlab*/
fprintf (fnp, " %. 10lf %.10lf \ n", x1_1, x2_1);
fprintf (fdp, " %. 10lf %.10lf \ n", x1_1, (ds -u_1)/ts);
x1 = x1_1;
x2 = x2_1;
u_1 = ds;
}
fclose (fp);
fclose (FNP);
fclose (fdp);
Printf ("Hello World! \ N");
Return 0;
}``````

4. Matlab drawing

``````Load ('C: \\ Users \ Terryc \ Documents \ CodeBlocks \ Micro Division \ fSt_yuan.txt');
LOAD ('C: \\ Users \ Terryc \ Documents \ CodeBlocks \ FST_now.txt');
LOAD ('C: \\ Users \ Terryc \ Documents \ CodeBlocks \ FST_DEV.TXT');
subplot (3,1,1);
plot (fst_yuan);
grid on;
subplot (3,1,2)
plot (fst_now);
grid on;
subplot (3,1,3)
plot (fst_dev);
grid on;``````

5. Result

In the middle of red is the output of the second -order microcompany, and the first -order microcompany is output. The interference noise is significantly suppressed.

source