I am trying to test the behavior of adding number in an array containing a string using the following code :
warning: implicit conversion from numeric to char
I do understand the error and all, but the weird thing is that I get squares for the numbers, as in the image and I don't understand what these are
CodePudding user response:
If you want to mix heterogeneous input data in an array with Octave, you must use a cell array as container, that is, use braces instead of brackets to "concatenate" data:
>> a6 = {"test", 3, 5}
a6 =
{
[1,1] = test
[1,2] = 3
[1,3] = 5
}
Otherwise, as commented by Raymond Chen, Octave tries to convert some data to make homogeneous (of the same type) their whole list.