Question
In the PSO-BP using Codes in MATLAB for Training Artificial Neural Network using Particle Swarm Optimization.
I have done the feedword in the backpropagation and then I had the errors result. thereafter I sent the weight to the PSO To find the local Best, best, updated velocityand updated position. But the result was not good enough. So please I want the matlab code according to the database below
The database I've take it from this website https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.names
Explanation / Answer
The code to your question is /* * File: kalmanfilter.c * * MATLAB Coder version : 3.3 * C/C++ source code generated on : 14-Feb-2017 18:47:44 */ /* Include Files */ #include "rt_nonfinite.h" #include "kalmanfilter.h" /* Variable Definitions */ static double x_est[6]; static double p_est[36]; /* Function Definitions */ /* * Arguments : const double z[2] * double y[2] * Return Type : void */ void kalmanfilter(const double z[2], double y[2]) { int r2; signed char Q[36]; int k; double x_prd[6]; int i0; double a21; double a[36]; double S[4]; int r1; double klm_gain[12]; double p_prd[36]; static const signed char b[36] = { 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }; static const signed char b_a[36] = { 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1 }; double a22; static const signed char c_a[12] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; double B[12]; static const short R[4] = { 1000, 0, 0, 1000 }; static const signed char b_b[12] = { 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }; double Y[12]; double b_z[2]; /* Copyright 2010 The MathWorks, Inc. */ /* Initialize state transition matrix */ /* % [x ] */ /* % [y ] */ /* % [Vx] */ /* % [Vy] */ /* % [Ax] */ /* [Ay] */ /* Initialize measurement matrix */ for (r2 = 0; r2 < 36; r2++) { Q[r2] = 0; } /* Initial state conditions */ /* Predicted state and covariance */ for (k = 0; k < 6; k++) { Q[k + 6 * k] = 1; x_prd[k] = 0.0; for (r2 = 0; r2 < 6; r2++) { a[k + 6 * r2] = 0.0; for (i0 = 0; i0 < 6; i0++) { a[k + 6 * r2] += (double)b_a[k + 6 * i0] * p_est[i0 + 6 * r2]; } x_prd[k] += (double)b_a[k + 6 * r2] * x_est[r2]; } } for (r2 = 0; r2 < 6; r2++) { for (i0 = 0; i0 < 6; i0++) { a21 = 0.0; for (r1 = 0; r1 < 6; r1++) { a21 += a[r2 + 6 * r1] * (double)b[r1 + 6 * i0]; } p_prd[r2 + 6 * i0] = a21 + (double)Q[r2 + 6 * i0]; } } /* Estimation */ for (r2 = 0; r2 < 2; r2++) { for (i0 = 0; i0 < 6; i0++) { klm_gain[r2 + (i0