how to use Matlab coder to generate C code with a binary tree

2 Ansichten (letzte 30 Tage)
Ma Yuelin
Ma Yuelin am 30 Okt. 2018
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;

Antworten (0)

Kategorien

Mehr zu Simulink PLC Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by