Matlab c code generation

1 回表示 (過去 30 日間)
Chiluveru Manishankar
Chiluveru Manishankar 2023 年 2 月 17 日
回答済み: Jatin 2024 年 8 月 30 日
Hi I am trying to generation c code form m file but I am getting erros like use {} instead of () for Cells but replacing () with {} is not correct way of synatx in matlab but error is asking me to replace that
  3 件のコメント
Sachin
Sachin 2023 年 2 月 17 日
Can you please provide code where you are getting error?
Matan Silver
Matan Silver 2023 年 3 月 13 日
Hi Chiluveru,
Are you still having trouble with this issue with code generation? Referring to the "cell" documentation:
"cell" does use bracket-based indexing (for example, myCell{1} will access the first element of the cell array myCell). However, it's still possible there could be an issue with MATLAB or Code Generation. Could you provide a reproduction script so we can generate the same error you are seeing, on our side? Thanks,
Matan

サインインしてコメントする。

回答 (1 件)

Jatin
Jatin 2024 年 8 月 30 日
If you go through the documentation of cell array it clearly says that we should use curly braces to access the contents of cells.
Parentheses are used to refer to sets of cells, Parentheses are also used for regular array indexing in MATLAB.
To help you understand here is an example script which uses cell array:
load("myCellArray.mat");
function cellArray = doubleCell(cellArray)
% Iterate through the cell array and double each numeric element
for i = 1:length(cellArray)
% Double the numeric array
cellArray{i} = 2 * cellArray{i};
end
end
Kindly refer to the documentation below for more information on Cell Arrays:

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by