7.2) Forming Strings: Concatenation
Sometimes we may want to construct strings from smaller strings. For example, we may want Matlab to plot a graph and have Matlab form a plot title by concatenating a strings with the data file name. Alternatively we may want to save a file with a file name that Matlab will derive according to some logical statement. How can we do this?
- Strings can be joined just like numerical vectors
- Alternatively the function strcat concatenates strings horizontally
[matlab]
>> firstname='Elvis'; secondname='Presley';
>> fullname=[firstname, ' ', secondname];
[/matlab]
[matlab]
>> fullname=strcat(firstname, secondname);
[/matlab]