编辑:谢谢,对那些感兴趣的人的固定代码:ert_main.cpp:

#include /* This ert_main.c example uses printf/fflush */

#include "Rx.h" /* Model's header file */

#include "rtwtypes.h" /* MathWorks types */

#include

#include

#include

#include

#include

#include

//#include //for writing results to file

//#include //doesn't work

#include

#define lengthOFSignal 5000

在主要功能上:

using namespace std;

std::vector<:string> words;

std::string word;

ifstream iFile;

string path = __FILE__; //gets source code path, include file name

path = path.substr(0,1+path.find_last_of('\\')); //removes file name

string testFileName = "LEGACY_R12_800BITS_40MHz.dat";

path+= testFileName; //adds input file to path

int signal_length=0;

std::vector real_part_VEC, imag_part_VEC;

std::istringstream ss;

real_T real_temp, imag_temp;

iFile.open(path,ios::binary );

//iFile.open(path.c_str(), ios::binary);

if (iFile.is_open()) {

while (std::getline(iFile, word)) {

words.push_back(word);

}

iFile.close();

}

signal_length=words.size();

for(int i=0; i< signal_length;i++)

{

ss.str(words[i]);

ss >> real_temp >> imag_temp;

real_part_VEC.push_back(real_temp);

imag_part_VEC.push_back(imag_temp);

}

real_T real_part[lengthOFSignal];

real_T imag_part[lengthOFSignal];

for (int i=0; i < signal_length; i++) {

real_part[i]=real_part_VEC[i];

imag_part[i]=imag_part_VEC[i];

}

/* Initialize model */

Rx_initialize(real_part,imag_part,signal_length);

旧代码和问题:

.dat文件看起来像是带有数字(以空格隔开)的两个直列

我收到有关循环读取数据的错误(strtok-> atof(空指针))

编辑了ert_main.cpp主要功能:

#include /* This ert_main.c example uses printf/fflush */

#include "Rx.h" /* Model's header file */

#include "rtwtypes.h" /* MathWorks types */

#include

#include "mat.h"

#define lengthOFSignal 5000

#define SizeOfLine 35

int_T main(int_T argc, const char *argv[])

{

/* Unused arguments */

(void)(argc);

(void)(argv);

int i=0;

char bFileName[] = "QPSK_SISO_802_11_packet_awgn_fr_shft.dat";

char chr[SizeOfLine*lengthOFSignal];

char *token;

real_T real_part[lengthOFSignal];

real_T image_part[lengthOFSignal];

int signal_length=0;

std::ifstream iFile(bFileName, std::ios::binary);

iFile.getline(chr,100);

for(int i=0; i

if (chr== NULL) break;

token= strtok(chr," ");

real_part[i]=atof(token); // real part.---problem occurs here!!!!

token= strtok(NULL," ");

image_part[i]=atof(token);// imaginary part.

iFile.getline(chr,100);

signal_length++;

}

iFile.close();

/* Initialize model */

Rx_initialize(real_part,image_part,signal_length);

/* Attach rt_OneStep to a timer or interrupt service routine with

* period 40.0 seconds (the model's base sample time) here. The

* call syntax for rt_OneStep is

*

* rt_OneStep();

*/

printf("Warning: The simulation will run forever. "

"Generated ERT main won't simulate model step behavior. "

"To change this behavior select the 'MAT-file logging' option.\n");

fflush((NULL));

while (rtmGetErrorStatus(Rx_M) == (NULL)) {

/* Perform other application tasks here */

rt_OneStep();

if(Rx_Y.EVM!=0) break;

}

/* Disable rt_OneStep() here */

/* Terminate model */

Rx_terminate();

return 0;

}

链接到解决方案(VS 2012) 链接到项目/解决方案

c语言编程无法生成dat文件格式,c++ - 无法从.dat文件读取数据(从Simulink创建的VS2012 C ++项目) - 堆栈内存溢出...相关推荐

  1. 正常血压c语言编程,关于测试血压的C语言编程,要求有纠错功能,最少能输入五组数据...

    以下是整理过后的代码: #include #include //hyperpiesia高压   loperpiesia 低压 int main() { printf("=========欢迎 ...

  2. tcpdf html 格式重叠,html - tcpdf(html2pdf)无法正确生成表格边框 - 堆栈内存溢出...

    我正在使用html2pdf生成pdf文件(即使用tcpdf库_tcpdf_5.0.002). 不幸的是,我无法正确生成表格边框. require_once('inc/html2pdf/html2pdf ...

  3. java随机产生若干个偶数完成求和_java - 创建随机生成器以生成并计算奇数对偶数 - 堆栈内存溢出...

    我真的非常困惑. 我已经进行过几次网络搜索,但找不到任何可以帮助我解决这一精确作业问题的信息. 涉及:Java,while循环,随机生成数字和扫描仪控制台输入. 我们必须完成main方法中的代码,以便 ...

  4. asn.1 rsa java_android - RSA公钥生成失败:“错误:0c0000be:ASN.1编码例程:OPENSSL_internal:WRONG_TAG” - 堆栈内存溢出...

    我有一种应生成RSA公钥的方法: import android.util.Base64; import java.io.IOException; import java.security.KeyFac ...

  5. 使用python 处理表格生成图表_教你用Python自动读取数据生成图表,产生的效益很可观...

    厌烦了每次都要在Excel里拖动数据来生成图形吧,这篇文章里,教你用Python自动读取Excel数据生成图表,然后Python 使用XlsxWriter模块在Excel工作表中绘制带有数据表的柱形图 ...

  6. java自动生成项目编号_java - Apache POI,在同一文档中创建项目符号点和编号列表 - 堆栈内存溢出...

    我试图用apache poi创建一个既包含圆点又包含编号列表的文档. 我想得到这样的结果. 名单: 清单1项目0 清单1项目1 清单1项目2 列表后的段落. 清单2: 清单2项目0 清单2项目1 清单 ...

  7. python批量生成图表_教你用Python自动读取数据生成图表,产生的效益很可观

    厌烦了每次都要在Excel里拖动数据来生成图形吧,这篇文章里,教你用Python自动读取Excel数据生成图表,然后Python 使用XlsxWriter模块在Excel工作表中绘制带有数据表的柱形图 ...

  8. c语言gcno文件位置,makefile - 具有覆盖率的CMake Ninja将gcno文件放在根二进制目录中 - 堆栈内存溢出...

    我正在使用忍者生成器通过cmake构建一个项目,并使用add_compile_options("$:-g;-O0;-ftest-coverage;-fprofile-arcs;-fno-bu ...

  9. c语言 删除小写字母,c++ - 使用C字符串和指针。 删除除小写字母和空格以外的所有字符 - 堆栈内存溢出...

    当您决定从字符串中删除一个字符时,您可以将剩余的字符向左移动一个位置,这很好,但是无论该字符的实际值如何,都可以在该字符开始移动后的位置跳过该字符是. 这就是为什么您在输出中看到不需要的字符的原因. ...

最新文章

  1. 开源工程师:Ubuntu 应该抛弃 32 位 ISO 镜像
  2. 第一阶段SCRUM冲刺 03
  3. UA PHYS515A 电磁理论V 电磁波与辐射11 简单辐射问题 电偶极子的辐射
  4. PHP 找出数值数组中不重复最大的10个数和最小的10个数
  5. 数据中心制冷基本原则及节能方案
  6. portainer 启动mysql_Docker管理工具Portainer
  7. 【CodeForces - 260B 】Ancient Prophesy (暴力匹配,BF算法,日期字符串)
  8. Django笔记:ORM模型
  9. linux磁盘写保护怎么修改_linux – mount:无法重新安装块设备/ dev / sda5读写,是写保护的...
  10. C语言基础专题 - 指针(编写中)
  11. Android 中进程的级别以及 Service 的优先级
  12. 官方下载:slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar
  13. js 用指定字符分割字符串
  14. 全网最全的划分VLAN的方法,走过路过不要错过
  15. 媒体在计算机科学中的两种含义,多媒体技术应用思考与练习题.doc
  16. 网页实现数据离线永久保存localStorage、storage
  17. package-lock和package-shrinkwrap
  18. 旁观面经-02-开发岗总结版
  19. 小米手机安装linux视频教程,屏幕失灵的小米5手机安装linuxdeploy centos7记录
  20. 风影ASP.NET基础教学 12 GridView详解

热门文章

  1. python 窗口键 键位码_滚轮键按一下 这些功能超方便
  2. 深度探索QT窗口系统——几何篇
  3. Qt ui-setupUi(this)的作用
  4. Windows 10下使用Anaconda安装TensorFlow1.8
  5. win7 64 php5ts.dll,windows7 64位 php5.3安装php_mongo.dll方法
  6. [转]Git 撤销操作
  7. 文档在线编辑组件的发展回顾与开发集成选择问题
  8. Linux系统安装oracle时,orainstRoot.sh,root.sh脚本的作用。
  9. Oracle读书笔记
  10. 仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表中为标识列指定显式值问题...