Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave strcat ignores added spaces

Octave adds spaces with strcat

In Octave I run these commands:

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

I get this result:

ans = hello

Instead of what I expected:

ans = hel lo

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?

like image 835
Eric Leschinski Avatar asked Oct 15 '25 14:10

Eric Leschinski


1 Answers

Hmm. It works how it is defined:

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

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

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

like image 185
pbhd Avatar answered Oct 18 '25 08:10

pbhd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!