MATLAB coder-Check for Run-Time Issues,the output of test file is totally wrong compared with the original MATLAB code output
Use MATLAB coder to convert MATLAB code into C code suitable for Xilinx ARM development. However, when the conversion process proceeded to the MEX function check step, I found that the output of the test file using MEX was inconsistent with the output of the MATLAB code running directly. Here are the results running directly in MATLAB:
As the official tutorial shows, I split the code that needs to be translated into a data file (.mat), a separately encapsulated function file (.m), and a script that calls this function file (.m). The check was then performed in MATLAB coder, but the results were inconsistent
Here is the code in the test file to load the data and call the function. I can’t figure out why the results of the test file were incorrect when all the checks passed. Perhaps the converted code itself is not equivalent?
Note: The drawing of the final result is directly related to RY_final, and the built-in functions used by the converted function such as eig, sort, etc. should also support the conversion (otherwise it will not pass the check).
clear all
load(‘Data_02.mat’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%R:core algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[RNb_cub ,RYNb_cub, RY_final] = …
CoreFunc(PSub_mat, SDoa, var_n, M, N, J, K, Bin, Sample_vec, Time, Array, c, f_vec, EigVecNL_0);
……some compute and Plot the resultUse MATLAB coder to convert MATLAB code into C code suitable for Xilinx ARM development. However, when the conversion process proceeded to the MEX function check step, I found that the output of the test file using MEX was inconsistent with the output of the MATLAB code running directly. Here are the results running directly in MATLAB:
As the official tutorial shows, I split the code that needs to be translated into a data file (.mat), a separately encapsulated function file (.m), and a script that calls this function file (.m). The check was then performed in MATLAB coder, but the results were inconsistent
Here is the code in the test file to load the data and call the function. I can’t figure out why the results of the test file were incorrect when all the checks passed. Perhaps the converted code itself is not equivalent?
Note: The drawing of the final result is directly related to RY_final, and the built-in functions used by the converted function such as eig, sort, etc. should also support the conversion (otherwise it will not pass the check).
clear all
load(‘Data_02.mat’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%R:core algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[RNb_cub ,RYNb_cub, RY_final] = …
CoreFunc(PSub_mat, SDoa, var_n, M, N, J, K, Bin, Sample_vec, Time, Array, c, f_vec, EigVecNL_0);
……some compute and Plot the result Use MATLAB coder to convert MATLAB code into C code suitable for Xilinx ARM development. However, when the conversion process proceeded to the MEX function check step, I found that the output of the test file using MEX was inconsistent with the output of the MATLAB code running directly. Here are the results running directly in MATLAB:
As the official tutorial shows, I split the code that needs to be translated into a data file (.mat), a separately encapsulated function file (.m), and a script that calls this function file (.m). The check was then performed in MATLAB coder, but the results were inconsistent
Here is the code in the test file to load the data and call the function. I can’t figure out why the results of the test file were incorrect when all the checks passed. Perhaps the converted code itself is not equivalent?
Note: The drawing of the final result is directly related to RY_final, and the built-in functions used by the converted function such as eig, sort, etc. should also support the conversion (otherwise it will not pass the check).
clear all
load(‘Data_02.mat’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%R:core algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[RNb_cub ,RYNb_cub, RY_final] = …
CoreFunc(PSub_mat, SDoa, var_n, M, N, J, K, Bin, Sample_vec, Time, Array, c, f_vec, EigVecNL_0);
……some compute and Plot the result code generation, c convert MATLAB Answers — New Questions