MATLAB coder alternatives for textread.

18 次查看(过去 30 天)
Hi,
I am trying to convert my matlab project to C++ using the coder but I am facing problems with reading some text files. After reading around I learned that Coder does not support textscan() or fgetl() or fgets() or fgetc() or fscanf() or sscanf() .
I am not that experienced with matlab so now I am stuck at this point.
I have files that contain complex numbers in the following format
-0.00006 +0.00027
-0.00018 -0.00009
-0.00015 -0.00003
-0.00009 +0.00006
-0.00018 -0.00003
-0.00012 +0.00003
+0.00006 +0.00009
+0.00000 +0.00018
-0.00006 -0.00003
+0.00006 +0.00006
+0.00009 +0.00000
+0.00000 +0.00000
+0.00003 -0.00003
+0.00003 +0.00012
+0.00012 -0.00003
+0.00003 -0.00003
-0.00012 -0.00006
-0.00015 -0.00006
Which I am trying to read into an array. And then some files in the following format.
1
2,1
3,2,1
4,3,1,2
2,1,5,4,3
5,1,6,4,2,3
4,6,7,5,2,1,3
6,1,4,5,2,8,7,3
7,6,2,9,8,4,1,3,5
9,10,4,6,8,2,5,3,1,7
11,6,4,3,1,8,5,7,2,10,9
.
.
.
.
What are some ways in which I can read these files into an array which is also accesptable by MATLAB coder. Any help is appreciated.
Thank you

采纳的回答

Darshan Ramakant Bhat
Below is the list of functions supported by MATLAB Coder as of latest release :
I can see that MATLAB Coder does support "fscanf" with some limitations, please read the "Extended capability" section in the doc for more info :
Hope this will be helpful.

更多回答(1 个)

dpb
dpb 2021-7-12
indicates beginning with R2019b Coder does support the above functionality albeit behavior may be different than that inside MATLAB, reverting to the base C language behavior.

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by