代码拉取完成,页面将自动刷新
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include "BPNN_PID.h"
#define Sample 40
using namespace std;
int main() {
double Target = 15,Current = 0;
double TestData[4][Sample] = {0};
BPNN_PID bpnnPid;
bpnnPid.TargetV = Target;
string Uof = "OutputU.txt";
string Kpof= "OutputKp.txt";
string Kiof= "OutputKi.txt";
string Kdof= "OutputKd.txt";
ofstream OutputU(Uof);
ofstream OutputKp(Kpof);
ofstream OutputKi(Kiof);
ofstream OutputKd(Kdof);
for (int i = 0; i < Sample; ++i)
{
bpnnPid.CurrentV = Current;
bpnnPid.GetU_Ctrl();
Current =Current + bpnnPid.U_Ctrl;
TestData[0][i] = Current;
TestData[1][i] = bpnnPid.bpnnWeight.w1;
TestData[2][i] = bpnnPid.bpnnWeight.w2;
TestData[3][i] = bpnnPid.bpnnWeight.w3;
}
if(OutputU.is_open() && OutputKp.is_open() && OutputKd.is_open() && OutputKi.is_open())
{
for (short i = 0 ; i < Sample ; i++)
{
OutputU << TestData[0][i] << endl;
OutputKp << TestData[1][i] << endl;
OutputKi << TestData[2][i] << endl;
OutputKd << TestData[3][i] << endl;
}
}
else
{
cout << "Error" << endl;
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。