MATLAB coder alternatives for textread.

조회 수: 15 (최근 30일)
Raghav Rathi
Raghav Rathi 2021년 7월 12일
댓글: Raghav Rathi 2021년 7월 13일
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일
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에서 Language Support에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by