How to concatenate strings in Octave
In order to concatenate strings, in GNU Octave, use this snippet:
% Concatenate and assign to a variable named "concatenated"
concatenated = strcat("test", "123");
% OPTIONAL: Show the value of the "concatenated" variable in the terminal
disp(concatenated); % Displays "test123" (without quotes) in the terminal
Similarly, you can concatenate three or more strings:
strcat("test", "123", "456"); # test123456
You don’t have to use literal strings, you can also use variables instead:
mystr = "xyz";
strcat("test", mystr, "456"); # testxyz456
Alternatively you can use this short syntax(no commata between the strings!):
concatenated = ["test" "123"]
% Show the value
disp(concatenated);