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
Darshan Ramakant Bhat 2021 年 7 月 13 日

1 投票

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 日

1 投票

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.

カテゴリ

ヘルプ センター および File 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