How to get x2fx as a function suitable for mat lab coder?

1 回表示 (過去 30 日間)
Ummi Hani
Ummi Hani 2018 年 8 月 14 日
編集済み: Ummi Hani 2018 年 8 月 14 日
I am trying to get the x2fx of matrixA. When using Matlab coder, it says that x2fx is not supported for standalone code generation. So I decided to write a separate function that produces the x2fx according to the number of columns in matrixA.
I want to be able to produce the x2fx of up to 3 columns in matrixA.
During my testing, my matrixA is set as 9 by 2. When I tried to convert my function using the matlab coder, I get an error saying "Index expression out of bounds. Attempted to access element 3. The valid range is 1-2."
It seems my if-else function did not work. I even tried using case-switch, but the same thing happened. My matrixA is a variable that can change. It is only 9x2 for testing purposes. How can I get rid of this error?
if NumofColumns==2
QuadDesignMatrix = zeros(NumofRows,6);
for ii = 1:NumofRows
x1=matrixA(ii,1);
x2=matrixA(ii,2);
QuadDesignMatrix(ii,:) = [1 x1 x2 x1*x2 x1^2 x2^2];
end
return
elseif NumofColumns==3
QuadDesignMatrix = zeros(NumofRows,10);
for ii = 1:NumofRows
x1=MatrixA(ii,1);
x2=MatrixA(ii,2);
x3=MatrixA(ii,3);
QuadDesignMatrix(ii,:) = [1 x1 x2 x3 x1*x2 x1*x3 x2*x3 x1^2 x2^2 x3^2];
end
return
else
error=1;
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeDesign of Experiments (DOE) についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by