I want to design a program of n = 3 instances. Each instance is pointing to an 'instance' position of an array. Each instance is composed of two values: {error, control}. When calling a function "run_instance" these two values change to other ones.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int Ki = 6;
int Kp = 4;
int n = 3;
int arr[n][2] = {
{0.1, 11},
{0.001, 21},
{0.0001, 31}
};
double measured_error = 0.3;
int instance = 2;
run_instance(instance, measured_error, Kp, Ki);
}
double run_instance(int instance, double measured_error, int Kp, int Ki)
{
//new value = 21 + Kp * measured_error + (Ki-Kp)*0.001 (last error of this instance)
//update arr[n][2] as{
// {0.1, 11},
// {measured_error, new_value},
// {0.0001, 31}
// }
//return new value = 21 + Kp * measured_error + (Ki-Kp)*0.001 (last error of this instance)
}