从Matlab编码器初始化主函数 我通过Matlab编码器创建了一个C++程序,称为隐式枚举。CPP以矩阵A和向量B作为输入,返回向量ZSTAR和概率值VSTAR。我现在正在努力初始化主函数: // Include Files #include "stdafx.h" #include "implicit_enumeration.h" #include "main.h" // Function Declarations static void argInit_4x1_real_T(double result[4]); static void argInit_4x9_real_T(double result[36]); static void main_implicit_enumeration(); // Function Definitions static void argInit_4x1_real_T(double result[4]) { int idx0; // Loop over the array to initialize each element. for (idx0 = 0; idx0 < 4; idx0++) { // Set the value of the array element. // Change this value to the value that the application requires. result[idx0] = 1; } } static void argInit_4x9_real_T(double result[36]) { int idx0; int idx1; // Loop over the array to initialize each element. for (idx0 = 0; idx0 < 4; idx0++) { for (idx1 = 0; idx1 < 9; idx1++) { // Set the value of the array element. // Change this value to the value that the application requires. if (idx0 == 0) { if (idx1 == 0) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 1) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else if (idx0 == 1) { if (idx1 == 2) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 3) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 4) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else if (idx0 == 2) { if (idx1 == 5) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else { if (idx1 == 6) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 7) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 8) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } } } } static void main_implicit_enumeration() { double dv0[36]; double dv1[4]; double zstar[9]; double Vstar; // Initialize function 'implicit_enumeration' input arguments. // Initialize function input argument 'A'. // Initialize function input argument 'b'. // Call the entry-point 'implicit_enumeration'. argInit_4x9_real_T(dv0); argInit_4x1_real_T(dv1); implicit_enumeration(dv0, dv1, zstar, &Vstar); } int main(int argc, const char * const argv[]) { // Initialize the application. // You do not need to do this more than one time. // Invoke the entry-point functions. // You can call entry-point functions multiple times. main_implicit_enumeration(); return 0; } //包含文件 #包括“stdafx.h” #包括“隐式枚举.h” #包括“main.h” //函数声明 静态无效值(双结果[4]); 静态无效值(双结果[36]); 静态void main_隐式_枚举(); //函数定义 静态无效数据(双结果[4]) { int-idx0; //循环数组以初始化每个元素。 对于(idx0=0;idx0

从Matlab编码器初始化主函数 我通过Matlab编码器创建了一个C++程序,称为隐式枚举。CPP以矩阵A和向量B作为输入,返回向量ZSTAR和概率值VSTAR。我现在正在努力初始化主函数: // Include Files #include "stdafx.h" #include "implicit_enumeration.h" #include "main.h" // Function Declarations static void argInit_4x1_real_T(double result[4]); static void argInit_4x9_real_T(double result[36]); static void main_implicit_enumeration(); // Function Definitions static void argInit_4x1_real_T(double result[4]) { int idx0; // Loop over the array to initialize each element. for (idx0 = 0; idx0 < 4; idx0++) { // Set the value of the array element. // Change this value to the value that the application requires. result[idx0] = 1; } } static void argInit_4x9_real_T(double result[36]) { int idx0; int idx1; // Loop over the array to initialize each element. for (idx0 = 0; idx0 < 4; idx0++) { for (idx1 = 0; idx1 < 9; idx1++) { // Set the value of the array element. // Change this value to the value that the application requires. if (idx0 == 0) { if (idx1 == 0) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 1) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else if (idx0 == 1) { if (idx1 == 2) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 3) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 4) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else if (idx0 == 2) { if (idx1 == 5) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } else { if (idx1 == 6) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 7) { result[idx0 + (idx1 << 2)] = 1; } else if (idx1 == 8) { result[idx0 + (idx1 << 2)] = 1; } else { result[idx0 + (idx1 << 2)] = 0; } } } } } static void main_implicit_enumeration() { double dv0[36]; double dv1[4]; double zstar[9]; double Vstar; // Initialize function 'implicit_enumeration' input arguments. // Initialize function input argument 'A'. // Initialize function input argument 'b'. // Call the entry-point 'implicit_enumeration'. argInit_4x9_real_T(dv0); argInit_4x1_real_T(dv1); implicit_enumeration(dv0, dv1, zstar, &Vstar); } int main(int argc, const char * const argv[]) { // Initialize the application. // You do not need to do this more than one time. // Invoke the entry-point functions. // You can call entry-point functions multiple times. main_implicit_enumeration(); return 0; } //包含文件 #包括“stdafx.h” #包括“隐式枚举.h” #包括“main.h” //函数声明 静态无效值(双结果[4]); 静态无效值(双结果[36]); 静态void main_隐式_枚举(); //函数定义 静态无效数据(双结果[4]) { int-idx0; //循环数组以初始化每个元素。 对于(idx0=0;idx0,c++,matlab,command-line-arguments,C++,Matlab,Command Line Arguments,实际上,您基本完成了 在main中(int argc,const char*const argv[]): argc是命令行参数的数量,argv包含这些命令行参数 例如: 如果调用test.ext something,argc是2,argv[0]是“test.exe”,argv[1]是“something” 您的初始化是在main_implicit_enumeration()中完成的 dv0是矩阵A(4*9矩阵->36个元素),它是 在argInit_4x9_real_T()中初始化 dv1是向

实际上,您基本完成了

在main中(int argc,const char*const argv[]): argc是命令行参数的数量,argv包含这些命令行参数

例如: 如果调用
test.ext something
,argc是2,argv[0]是“test.exe”,argv[1]是“something”

您的初始化是在main_implicit_enumeration()中完成的

  • dv0是矩阵A(4*9矩阵->36个元素),它是 在argInit_4x9_real_T()中初始化
  • dv1是向量b(4个向量->4个元素),它在argInit\u 4x1\u real\T中初始化
  • zstar是返回向量
  • 斯卡拉返回星

问题是:您想如何将值传递给您的程序?从文件加载值?使用类似于
test.ext a=1,2,3;4,5,6 b=8,9的格式?

argv[]
未在代码中使用。不清楚“初始化主函数”的含义