MATLAB: Create string from a cell array

cell arraystring

Hi,
I have a list of names in a 1 by n matrix. I would like to make them into one string (to generate file names, the end result of my program saves a graph to a file). The names are from varargin (which allows variable amount of inputs)
names=varargin;
I have tried using:
char(names)
This does give a character result, but over n rows. I want one string. Ideally, I would be able to seperate names with underscores, but I would settle for just a string (no spaces) of the names.
Any help would be great.

Best Answer

Simple and fast:
Str = sprintf('%s_', varargin{:});
Str(end) = [];
But if the cell string has a lot of elements, this can be imrpoved: Obviously SPRINTF does not preallocate the complete string at first. Then try: FEX: CStr2String.