以向量开头的格式写入txt文件?

发布于 2024-09-18 07:34:11 字数 470 浏览 3 评论 0原文

我想做与这个问题中解释的相反的事情:

从 MATLAB 获取数据的问题

我会传递向量(例如. <代码>代码服务 = [NNNNNNNNNN ....] area = [IIIIIII ....] [.........]) 创建与链接中格式相同的文本文件,即:

* Comment line
| Code | serv | etc. ...
* Comment line
Figures | Figures | Figures | etc. ......

我们必须重建一个新驱动器,否则您可以调整代码?

感谢您的帮助和相关信息。

I want to do the opposite of what has been explained in this question:

problems with data acquisition from MATLAB

I would pass by the vectors (eg. codeserv = [NNNNNNNNNN ....]
area = [IIIIIII ....] [.........]
) to create the text file with the same format as in the link, ie:

* Comment line
| Code | serv | etc. ...
* Comment line
Figures | Figures | Figures | etc. ......

We must rebuild a new drive or you can adapt the code?

Thanks for your help and information about it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北城孤痞 2024-09-25 07:34:11

这是一个小示例,可以帮助您将第一个文件从 Matlab 保存到硬盘上。

%some nr to integrate into the printf
num=2.0 
%opens the file: 'file_name' with write access 
f = fopen(file_name,'w');
%writes some text into the file
fprintf(f,'test-file dump\r\n');
%writes text and includes a fload number out of matlab workspace
fprintf(f,'some-float=%f \r\n', num);
%important closes the file, other wise no other program can grand write access on the file
fclose(f);

希望它有帮助。

Here is a little sample, what should help you to save your first file out of Matlab onto your hard drive.

%some nr to integrate into the printf
num=2.0 
%opens the file: 'file_name' with write access 
f = fopen(file_name,'w');
%writes some text into the file
fprintf(f,'test-file dump\r\n');
%writes text and includes a fload number out of matlab workspace
fprintf(f,'some-float=%f \r\n', num);
%important closes the file, other wise no other program can grand write access on the file
fclose(f);

Hopefully it helps.

有木有妳兜一样 2024-09-25 07:34:11

您可以使用 fprintf 进行输出,而不是使用 textscan 来扫描某些输入。

Instead of using textscan in order to scan some input, you may use fprintf for output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文