disp("You can throw a forehand about " + f + " meters which means you can throw a backhand about " + b + " meters.")
You can throw a forehand about 10 meters which means you can throw a backhand about 15 meters.
The "+" operator is only defined for strings, not char variables...
The char() string is an array of char so trying to add
msg1='You can throw a forehand about ';
whos msg1
Name Size Bytes Class Attributes
msg1 1x31 62 char
msg1+f
ans =
99 121 127 42 109 107 120 42 126 114 124 121 129 42 107 42 112 121 124 111 114 107 120 110 42 107 108 121 127 126
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
whos ans
Name Size Bytes Class Attributes
ans 1x31 248 double
results in an array in which the value of f has been added to the value of the char() string -- which is an integer which matches the specific character in the ASCII table; internally they're still just numbers; it's only knowing to display as a char() variable that makes it look like text instead...
msg2='meters which means you can throw a backhand about ';
whos msg2
Name Size Bytes Class Attributes
msg2 1x50 100 char
Now you see that msg1 and msg2 aren't the same length and therefore, can't be added. Of course, even if they just happened to have the same length having added 10 to the first message, it wouldn't be at all what was intended...
char(msg1+f)
ans = 'cy□*mkx*~r|y□*k*py|orkxn*kly□~*'
The olden way of doing this before the strings class was introduced, one did the above with explicit formatting as msg=sprintf('You can throw a forehand about %f meters which means you can throw a backhand about %f meters.',f,b);
disp(msg)
You can throw a forehand about 10.000000 meters which means you can throw a backhand about 15.000000 meters.