在Matlab中使用dlmcell进行换行-在Notepad ++中显示但不在Notepad中显示 [英] Line breaks using dlmcell in Matlab - shows up in Notepad++ but not Notepad

查看:138
本文介绍了在Matlab中使用dlmcell进行换行-在Notepad ++中显示但不在Notepad中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Matlab中使用函数dlmcell来输出文本.每次使用dlmcell追加内容时,我都希望在新行上输入文字.

I am using the function dlmcell in Matlab to output text. I want text on a new line each time I append using dlmcell.

当我在Notepad ++中打开书面文档时,每个文本片段都按需要放在新行上.但是,在Windows附带的记事本中打开它,一切都在同一行上.有人可以告诉我这是为什么,以及如何解决吗?

When I open my written document in Notepad++, each snippet of text is on a new line as I want it. However, opening it in Notepad that comes with windows, everything is on the same line. Can somebody tell me why this is, and how to fix it?

推荐答案

我假设您正在使用字符串\n在输出中声明新行.对于Notepad ++,这已经足够了,因为它仅用\n解释了一行.对于Windows编辑器,您还需要包括回车费:

I'm assuming you're using the string \n to declare a new line in your output. For Notepad++ this is sufficient, because it interprets a new line just with \n. For the Windows Editor you need to include the carriage return also:

替代:

\n\r\n

这样,不仅创建了新行,而且还告诉编辑器实际在下一行继续.

This way not just a new line is created, it also tells the editor to actually continue on the next line.

为说明我的意思,请使用Notepad ++打开输出文件,然后激活查看>显示符号>所有字符,您将看到类似以下内容的

To illustrate what I mean, open your output file with Notepad++ and activate View > Show Symbol > All characters and you will see something like:

我是用Notepad ++编写的,它会在每行末尾自动添加 CR (回车)和 LF (换行).如果您不告诉,Matlab不会.因此,您的输出文件仅包含 LF ,而没有上述替代.

I wrote this with Notepad++ and it automatically adds CR (carriage return) and LF (line feed) at the end of every line. Matlab doesn't if you don't tell it. So your output file only contains LF without the above mentioned substitution.

我研究了FEX函数dlmcell.在当前版本中,\r\n实际上已实现.您是否具有该功能的最新版本(下载)?如果不是,则肯定有其他问题,请发布一些代码.

I've had a look into dlmcell, which is a FEX-function. In the current version \r\n is implemented actually. Do you have the newest version of that function (Download)? If not, something else must be wrong, please post some code.

这篇关于在Matlab中使用dlmcell进行换行-在Notepad ++中显示但不在Notepad中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆