八度strcat忽略添加的空格 [英] Octave strcat ignores added spaces

查看:249
本文介绍了八度strcat忽略添加的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

八度使用strcat添加空格

在Octave中,我运行以下命令:

In Octave I run these commands:

strcat ("hel", " ", "lo") 

我得到这个结果:

ans = hello

而不是我所期望的:

ans = hel lo

strcat对我来说听起来像是连接字符串".空格是有效字符,因此添加空格应该可以. Matlab具有相同的行为,因此可能是有意的.

strcat to me sounds like "concatenate strings". A space is a valid character, so adding a space should be OK. Matlab has the same behaviour, so it's probably intended.

我发现它与直觉相反.这种行为有意义吗?

I find it counter intuitive. Does this behavior makes sense?

推荐答案

嗯.它的定义方式有效:

Hmm. It works how it is defined:

"strcat删除了参数中的尾部空格(单元格数组中的空格除外),而cstrcat则保留了空白."

"strcat removes trailing white space in the arguments (except within cell arrays), while cstrcat leaves white space untouched. "

来自 http://www.gnu.org/software /octave/doc/interpreter/Concatenating-Strings.html

所以问题可能是:这种行为是否应该改变.

So the question could be: Should this behaviour be changed.

这篇关于八度strcat忽略添加的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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