how to use Matlab coder to generate C code with a binary tree
조회 수: 2 (최근 30일)
이전 댓글 표시
I just want to generate C code where a binary tree is involved. following is the related code, in which I have a structure named "node", which contains members "left" and "right". I want "left" and "right" can also be a "node" structure.
But I always get errors when generating the C code, saying "the Structures don't match". I understand that I need to make sure the new node assigned to left should have the same structure, but don't know how to realize that.
function node=tree()
% initialize the root node
node.val=1;
node.left=struct();
node.right=struct();
% create a new node and assign to left
nkd.val=2;
nkd.left=struct();
nkd.right=struct();
node.left=nkd;
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink PLC Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!