Doug's MATLAB Video Tutorials

July 15th, 2010

Building strings from variables

Lots of MATLAB functions want strings as inputs. Very often MATLAB users want to use the value of a variable in that string. This video tutorial shows how to do that.

2 Responses to “Building strings from variables”

  1. Christos Saragiotis replied on :

    Instead of using string concatenation, one could use the sprintf command as well. E.g. replace the titleString line with

    titleString = sprintf('mode number: %d',modeShape);
    

    sprintf is more flexible especially when you want a lot of variables to appear in the string:

  2. Nike Force replied on :

    You got a really useful blog I have been here reading for about an hour. I am a newbie and your successNike Force is very much an inspiration for me.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.