MATLAB coder alternatives for textread.

19 views (last 30 days)
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

Accepted Answer

Darshan Ramakant Bhat
Darshan Ramakant Bhat on 13 Jul 2021
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.

More Answers (1)

dpb
dpb on 12 Jul 2021
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.

Categories

Find more on Language Support in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!