Saturday, September 17, 2016

Matlab: Concatenating string and integer

Here is how we can concatenate an integer to a string in matlab.

Let us say we have a string "test" and we want to generate the string test1,test2,test3 so on. We can do it by using the function strcat, which concatenates two strings passed as input to it. But as the numbers 1,2,3 etc are numbers we need to convert them to strings using the function int2str.

int2str takes an integer number as returns it by converting it into a string.

y will be equal to test1 as we converted 1 to string and concatenated it with the sting 'test'.

Example program 1


Example program 2


No comments:

Post a Comment

Follow by Email