how to use Matlab coder to generate C code with a binary tree
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Simulink PLC Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!