Revision 1378, 0.9 kB
(checked in by smidl, 14 years ago)
|
mex file for matlab
|
Line | |
---|
1 | #include "mex.h" |
---|
2 | #include "simulator.h" |
---|
3 | |
---|
4 | void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { |
---|
5 | double usa, usb; |
---|
6 | double *x_out, *y_out; |
---|
7 | |
---|
8 | /* Check the number of inputs and output arguments */ |
---|
9 | if ( n_input==2 ) { |
---|
10 | usa = *mxGetPr(input[0]); |
---|
11 | usb = *mxGetPr(input[1]); |
---|
12 | pmsmsim_noreg_step(usa,usb); |
---|
13 | } |
---|
14 | if ( n_input==1 ) { |
---|
15 | double Ww = *mxGetPr(input[0]); |
---|
16 | for (int i=0;i<125; i++){ |
---|
17 | pmsmsim_step(Ww,0.0); |
---|
18 | } |
---|
19 | } |
---|
20 | if (n_input==0){ |
---|
21 | pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, 1e-6 ); |
---|
22 | } |
---|
23 | |
---|
24 | output[0]= mxCreateDoubleMatrix(9, 1, mxREAL); |
---|
25 | x_out= mxGetPr(output[0]); |
---|
26 | |
---|
27 | for (int i=0; i<9; i++){ |
---|
28 | x_out[i]=x[i]; |
---|
29 | } |
---|
30 | |
---|
31 | output[1]= mxCreateDoubleMatrix(6, 1, mxREAL); |
---|
32 | y_out= mxGetPr(output[1]); |
---|
33 | |
---|
34 | for (int i=0; i<5; i++){ |
---|
35 | y_out[i]=KalmanObs[i]; |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | } |
---|