Alternatives for str2num function not supported for code generation
显示 更早的评论
Hi All,
The following function `str2num` is not supported for code generation.
nodes = str2num(char(G.Nodes.Name));
The nodes names were assigned using the below
G = graph(tail,head);
G.Nodes.Name = cellstr(string(1:height(G.Nodes))');
Other instances where I'm using `str2num`
t = str2num(GraphEdges{edge}(1));
h = str2num(GraphEdges{edge}(2));
Suggestion on an alternate function to str2num that could be used for code generation will be really helpful.
2 个评论
Stephen23
2023-10-4
STR2DOUBLE, SSCANF, etc... but which one to select depends largely on the data format.
Deepa Maheshvare
2023-10-4
回答(1 个)
G.Nodes.Name=cellstr(num2str([1:9].')); % make example struct
N=str2double(G.Nodes.Name) % convert to numeric
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!